Using rxjs v6
So I have multiple variables that I want to track/observe, and when any of them change, trigger an Observable to call an API, which then updates something else based on those variables.
I thought I could maybe trigger an event on a div
to force the observable to do something, but it's not returning results based on what I want
E.g.
var a, b, c, d // if any updates, should trigger div "update" event
let obs = fromEvent(this.$refs.updater, "update")
.pipe(
switchMap(i => {return this.callAnAPI()})
)
obs.subscribe()
var update = new Event("update")
this.$refs.updater.dispatchEvent(update)
However, there is no subscribe method on the observable. I was trying to modify one of my other Observables (which works)
fromEvent(input, "keyup")
.pipe(
map(i => i.currentTarget.value),
debounceTime(delay),
distinctUntilChanged(),
switchMap(value =>
{
this.page = 1
if (ajax)
{
return ajax
}
else
{
return this.axiosAjax({
path,
method,
data: {
...data,
[term]: value
}
})
}
})
)
update
a custom event listener? because there is no event listener calledupdate
as far as I know – Jacob Goh