1
我使用angular2 rxjs來測試它的組播FUNC,這裏是我的代碼:angular2類型「主題<{}>」是不能分配給輸入「()=>主題<number>」
var source = Observable.from([1, 2, 3]);
var subject = new Subject();
var multicasted = source.multicast(subject);
// These are, under the hood, `subject.subscribe({...})`:
multicasted.subscribe({
next: (v) => console.log('observerA: ' + v)
});
multicasted.subscribe({
next: (v) => console.log('observerB: ' + v)
});
// This is, under the hood, `source.subscribe(subject)`:
multicasted.connect();
我得到了錯誤的信息:
類型的參數「主題< {}>」是不能分配給類型
'Subject<number> | (() => Subject<number>)'.
Type 'Subject<{}>' is not assignable to type '() => Subject<number>'.
Type 'Subject<{}>' provides no match for the signature '(): Subject<number>'
嘗試'無功受=新主題();' –
yurzui