Reputation: 3029
Looking through my code base, I've noticed that a previous developer, when creating a function to transform one model to another, commonly uses the following code:
property: Observable.from([true]);
What does this accomplish exactly and why can't the value just be set to true
?
According to the documentation, the from
operator:
Creates an Observable from an Array, an array-like object, a Promise, an iterable object, or an Observable-like object.
Why should we use the from
operator if the array is only ever 1 value?
Upvotes: 0
Views: 181
Reputation: 1740
I am guessing, these are conventions followed by some teams or individuals, where
property
is of type Observable<boolean>
, which means this member data is calculated asynchronously (and is most likely to be used with an async
pipe in the HTML incase of angular).Upvotes: 1