我用谷歌搜索了很多,试图查看 d.ts 文件,但仍然无法理解出了什么问题。找不到 RxJs5 如何使用此功能的示例。
var source = Observable.fromEvent(document.body, 'keypress');
var delayedSource = source.delay(1000);
var obs = source
.buffer(() => {
return delayedSource;
})
.map((clickBuffer) => {
return clickBuffer.length;
});
我收到错误:
错误:(166, 15) TS2345:'() => Observable<{}>' 类型的参数不可分配给'Observable' 类型的参数。类型“() => Observable<{}>”中缺少属性“_isScalar”。
buffer.d.ts 看起来是这样,我想我应该从中理解,但我不能。
import { Observable } from '../Observable';
/**
* Buffers the incoming observable values until the passed `closingNotifier`
* emits a value, at which point it emits the buffer on the returned observable
* and starts a new buffer internally, awaiting the next time `closingNotifier`
* emits.
*
* <img src="./img/buffer.png" width="100%">
*
* @param {Observable<any>} closingNotifier an Observable that signals the
* buffer to be emitted} from the returned observable.
* @returns {Observable<T[]>} an Observable of buffers, which are arrays of
* values.
*/
export declare function buffer<T>(closingNotifier: Observable<any>): Observable<T[]>;
export interface BufferSignature<T> {
(closingNotifier: Observable<any>): Observable<T[]>;
}