IT:AD:RXJS:HowTo
Notes
One thing that got me at first was the difference between
forEach and map.
Foreach operates on each object (
Map operates on the whole array. In other words:
var src = [...]; var ids = src.map(x=>x.id); is exactly the same as the longer approach of var ids = [];src.forEach(x=>ids.push(x.id)); </sxh"> </callout> Convert an array to an observable: <sxh javascript> let srcArray = ['foo', 'bar']; let srcObservable = Rx.Observable.from(srcArray)
Perform an operation on every element within Observable array:
srcObservable.map(x => `Hello ${x}`);
Subscribe to observable:
srcObservable.subscribe(x => console.log(x) ); //The output will be: // 'Hi foo' // 'Hi bar'
## Resources ##
- /home/skysigal/public_html/data/pages/it/ad/rxjs/howto/home.txt
- Last modified: 2023/11/04 01:55
- by 127.0.0.1