I need to create a subscription to an Observable
that is immediately disposed of when it is first called.
Is there something like:
obser
I had similar question.
Below was called even later on from different state changers. As I did not want to.
function foo() {
// this was called many times which was not needed
observable.subscribe(func);
changeObservableState("new value");
}
I decided to try unsubscribe()
after subscribe as below.
function foo() {
// this was called ONE TIME
observable.subscribe(func).unsubscribe();
changeObservableState("new value");
}
subscribe(func).unsubscribe();
is like subscribeOnce(func)
.
I hope that helped you too.