I am looking to create an Observable that can emit a boolean value and be modified by a function.
My attempt was:
showModal$ = new Observable<boolean>();
Unfortunately, this approach did not work as expected.
What I really need is for showModal$
to default to false
, with the ability to change its value using a function like:
change() {
this.showModal$ = !this.showModal$;
}
I am working with Angular2 and would like to subscribe to this Observable from various components.
Could you suggest the best way to accomplish this?