本文整理汇总了TypeScript中xstream.Stream.remember方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Stream.remember方法的具体用法?TypeScript Stream.remember怎么用?TypeScript Stream.remember使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类xstream.Stream
的用法示例。
在下文中一共展示了Stream.remember方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: DOMDriver
function DOMDriver(vnode$: Stream<VNode>, name = 'DOM'): MainDOMSource {
domDriverInputGuard(vnode$);
const sanitation$ = xs.create<null>();
const firstRoot$ = domReady$.map(() => {
const firstRoot = getValidNode(container) || document.body;
vnodeWrapper = new VNodeWrapper(firstRoot);
return firstRoot;
});
// We need to subscribe to the sink (i.e. vnode$) synchronously inside this
// driver, and not later in the map().flatten() because this sink is in
// reality a SinkProxy from @cycle/run, and we don't want to miss the first
// emission when the main() is connected to the drivers.
// Read more in issue #739.
const rememberedVNode$ = vnode$.remember();
rememberedVNode$.addListener({});
// The mutation observer internal to mutationConfirmed$ should
// exist before elementAfterPatch$ calls mutationObserver.observe()
mutationConfirmed$.addListener({});
const elementAfterPatch$ = firstRoot$
.map(
firstRoot =>
xs
.merge(rememberedVNode$.endWhen(sanitation$), sanitation$)
.map(vnode => vnodeWrapper.call(vnode))
.startWith(addRootScope(toVNode(firstRoot)))
.fold(patch, toVNode(firstRoot))
.drop(1)
.map(unwrapElementFromVNode)
.startWith(firstRoot as any)
.map(el => {
mutationObserver.observe(el, {
childList: true,
attributes: true,
characterData: true,
subtree: true,
attributeOldValue: true,
characterDataOldValue: true,
});
return el;
})
.compose(dropCompletion) // don't complete this stream
)
.flatten();
const rootElement$ = concat(domReady$, mutationConfirmed$)
.endWhen(sanitation$)
.compose(sampleCombine(elementAfterPatch$))
.map(arr => arr[1])
.remember();
// Start the snabbdom patching, over time
rootElement$.addListener({error: reportSnabbdomError});
const delegator = new EventDelegator(rootElement$, isolateModule);
return new MainDOMSource(
rootElement$,
sanitation$,
[],
isolateModule,
delegator,
name
);
}