本文整理汇总了TypeScript中xstream.Stream.subscribe方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Stream.subscribe方法的具体用法?TypeScript Stream.subscribe怎么用?TypeScript Stream.subscribe使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xstream.Stream
的用法示例。
在下文中一共展示了Stream.subscribe方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: setTimeout
setTimeout(() => {
sink.subscribe({
next(x) {
assert.strictEqual(x, expected.shift());
},
error() {},
complete() {},
});
});
示例2: makeCallOnHistory
export function createHistory$(history: History,
sink$: Stream<HistoryInput | string>): MemoryStream<Location> {
const history$ = xs.createWithMemory<Location>().startWith(history.location);
const call = makeCallOnHistory(history);
const unlisten = history.listen((loc: Location) => { history$._n(loc); });
const sub = sink$.subscribe(createObserver(call, unlisten));
(history$ as any).dispose = () => { sub.unsubscribe(); unlisten(); };
return history$;
};
示例3: testDriver
function testDriver(sink: Stream<string>) {
sink.subscribe({
next: x => {
assert.strictEqual(testDriverExpected.length, 1);
assert.strictEqual(x, testDriverExpected.shift());
assert.strictEqual(testDriverExpected.length, 0);
done();
},
});
}
示例4: setTimeout
setTimeout(() => {
while (buffer.length > 0) {
const x = buffer.shift();
assert.strictEqual(x, expected.shift());
}
sink.subscribe({
next(x) {
assert.strictEqual(x, expected.shift());
},
error() {},
complete() {},
});
});