Ninja Ninja - 8 months ago 40
AngularJS Question

can I get an observable value synchronically? (Angular/ReactiveX)

I have an boolean observable in my project that called

, this is how it declared:

isPossible: Observable<boolean>;

I want to add condition that this is
, but I want to add it to a place where other conditions are evaluate synchronically, the only way i know how to use the value of observable is with async
{{isPossible | async}}
, but here I need to get it can I do it?


Think of Observable as a kind of Promise which can return more than one value over time. In this case you're creating asynchronous stream which is emitting boolean values. The way you can react to the values is to put your action on subscribe of the stream and then you get the real value:

isPossible.subscribe((latestIsPossibleValue: boolean) => {
  if (latestIsPossibleValue) {
    // do something on 'true'

Could you please expand more on the case you've got?