本文整理匯總了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);
}