.
map() ( ), map(), forEach() :
new Observable.of(testData)
.map(contractsData => {
var objects = [];
JSON.parse(contractsData).forEach(o => objects.push(new Contract(o['id'], o['description'])));
return objects;
})
.subscribe(val => console.log(val));
, .
-: http://plnkr.co/edit/NQgRVSCQGgPvTkPPGz7O ( , , ).
map(), :
new Observable.of(testData)
.map(contractsData => JSON.parse(contractsData).map(o => new Contract(o['id'], o['description'])))
.subscribe(val => console.log(val));
Btw, all statements ending in *allwork with a higher order of Observables (aka Observables emitting other Observables), and I was surprised that your code works because you are passing a regular array .concatAll()instead of Observable. This turned out to be an undocumented feature .concatAll()thanks to its extension . According to the documentation, this should not work.
source
share