1
我是新來RXJS,什麼會是更好的應對方法:反應式編程,將一個對象數組映射到只有一個對象字段的數組?
this.names$ = this.updates$.map(objects => objects.map((object) => object['name']));
我是新來RXJS,什麼會是更好的應對方法:反應式編程,將一個對象數組映射到只有一個對象字段的數組?
this.names$ = this.updates$.map(objects => objects.map((object) => object['name']));
RxJs是懶。這意味着如果你不打電話subscribe
它不會做任何事情。
假設this.updates$
爲Observable
:
this.updates$.map(objects => objects.json())
.subscribe(x => this.names$ = x.aField.map(obj => obj['name']));
aField
是其中array of object
存儲在你的響應結構的字段中。