【发布时间】:2018-11-09 08:26:08
【问题描述】:
我有一个可观察对象,它发出一组对象。我需要使用哪些管道操作符将其转换为 Observable 以便我可以对每个对象进行操作?
我需要对 obs$ 做什么才能使其像 obs2$ 一样发出?
const obs$ = of([{ opponent: 'Walton', team: 'varsity', gametime: new Date() },
{ opponent: 'Scott', team: 'varsity', gametime: new Date() },
{ opponent: 'Dixie', team: 'varsity', gametime: new Date() },
{ opponent: 'Highlands', team: 'freshmen', gametime: new Date() }])
.pipe(
tap(console.log)
);
obs$.subscribe(a =>
console.log(a)
);
const obs2$ = of({ opponent: 'Walton', team: 'varsity', gametime: new Date() },
{ opponent: 'Scott', team: 'varsity', gametime: new Date() },
{ opponent: 'Dixie', team: 'varsity', gametime: new Date() },
{ opponent: 'Highlands', team: 'freshmen', gametime: new Date() })
.pipe(
tap(console.log)
);
obs2$.subscribe(a =>
console.log(a)
);
【问题讨论】:
标签: typescript rxjs observable rxjs6