angular 上的 ForkJoin 问题
ForkJoin Issue on angular
我为测试 forkJoin 编写了这段代码,但它不起作用!
你能检查一下是什么问题吗?
const observables = [];
observables.push(new Observable(subscriber => subscriber.next('Hello')));
observables.push(new Observable(subscriber => subscriber.next(' ')));
observables.push(new Observable(subscriber => subscriber.next('World') ));
observables.push(new Observable(subscriber => subscriber.next('!')));
forkJoin(observables).subscribe(word => console.log(word.join('')));
试试这个
const observables = [];
observables.push(Observable.of('Hello'));
observables.push(Observable.of(' '));
observables.push(Observable.of('World'));
observables.push(Observable.of('!'));
Observable.forkJoin(observables).subscribe(word => console.log(word.join('')));
重要的是完成 forkJoin 工作的 observable,就像这个例子!
const observables = [];
observables.push(new Observable(subscriber => {
subscriber.next('Hello');
subscriber.complete();
}));
observables.push(new Observable(subscriber => {
subscriber.next(' ');
subscriber.complete();
}));
observables.push(new Observable(subscriber => {
subscriber.next('World');
subscriber.complete();
}));
observables.push(new Observable(subscriber => {
subscriber.next('!');
subscriber.complete();
}));
forkJoin(observables).subscribe(word => console.log(word.join('')));
我为测试 forkJoin 编写了这段代码,但它不起作用! 你能检查一下是什么问题吗?
const observables = [];
observables.push(new Observable(subscriber => subscriber.next('Hello')));
observables.push(new Observable(subscriber => subscriber.next(' ')));
observables.push(new Observable(subscriber => subscriber.next('World') ));
observables.push(new Observable(subscriber => subscriber.next('!')));
forkJoin(observables).subscribe(word => console.log(word.join('')));
试试这个
const observables = [];
observables.push(Observable.of('Hello'));
observables.push(Observable.of(' '));
observables.push(Observable.of('World'));
observables.push(Observable.of('!'));
Observable.forkJoin(observables).subscribe(word => console.log(word.join('')));
重要的是完成 forkJoin 工作的 observable,就像这个例子!
const observables = [];
observables.push(new Observable(subscriber => {
subscriber.next('Hello');
subscriber.complete();
}));
observables.push(new Observable(subscriber => {
subscriber.next(' ');
subscriber.complete();
}));
observables.push(new Observable(subscriber => {
subscriber.next('World');
subscriber.complete();
}));
observables.push(new Observable(subscriber => {
subscriber.next('!');
subscriber.complete();
}));
forkJoin(observables).subscribe(word => console.log(word.join('')));