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?
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).
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.