本文整理汇总了TypeScript中xstream.createWithMemory函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createWithMemory函数的具体用法?TypeScript createWithMemory怎么用?TypeScript createWithMemory使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createWithMemory函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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$;
};
示例2:
function makeSinkProxies<So extends Sources, Si extends Sinks>(
drivers: Drivers<So, Si>): SinkProxies<Si> {
const sinkProxies: SinkProxies<Si> = {} as SinkProxies<Si>;
for (const name in drivers) {
if (drivers.hasOwnProperty(name)) {
sinkProxies[name] = xs.createWithMemory<any>();
}
}
return sinkProxies;
}
示例3: record
return function record(stream: Stream<any>): Stream<any> {
const recordedStream = xs.createWithMemory({
start(listener) {
xs.fromObservable(stream).addListener(
recordListener(currentTime, listener)
);
},
stop() {},
});
return adapt(recordedStream);
};