本文整理汇总了TypeScript中snabbdom/tovnode.toVNode函数的典型用法代码示例。如果您正苦于以下问题:TypeScript toVNode函数的具体用法?TypeScript toVNode怎么用?TypeScript toVNode使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了toVNode函数的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: DOMDriver
function DOMDriver(vnode$: Stream<VNode>, name = 'DOM'): MainDOMSource {
domDriverInputGuard(vnode$);
const sanitation$ = xs.create<null>();
const rootElement$ = xs
.merge(vnode$.endWhen(sanitation$), sanitation$)
.map(vnode => vnodeWrapper.call(vnode))
.fold(patch, toVNode(rootElement))
.drop(1)
.map(unwrapElementFromVNode)
.compose(dropCompletion) // don't complete this stream
.startWith(rootElement as any);
// Start the snabbdom patching, over time
const listener = {error: reportSnabbdomError};
if (document.readyState === 'loading') {
document.addEventListener('readystatechange', () => {
if (document.readyState === 'interactive') {
rootElement$.addListener(listener);
}
});
} else {
rootElement$.addListener(listener);
}
return new MainDOMSource(
rootElement$,
sanitation$,
[],
isolateModule,
delegators,
name,
);
}
示例2: toVNode
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
示例3: injectUI
export default function injectUI(streamContainer: Element) {
var nfeContainer = document.createElement('div');
nfeContainer.id = 'nfe-container';
streamContainer.appendChild(nfeContainer);
const patch = init([propsModule, attrsModule, eventsModule]);
let vnode = toVNode(nfeContainer);
storePromise
.then(store => {
const render = () => {
const newVnode = h('div#nfe-container', [NewsFeedEradicator(store)]);
patch(vnode, newVnode);
vnode = newVnode;
};
render();
store.subscribe(render);
})
.catch(handleError);
}