本文整理匯總了TypeScript中dojo-core/WeakMap.delete函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript delete函數的具體用法?TypeScript delete怎麽用?TypeScript delete使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了delete函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: setTabListeners
/**
* A utility function that sets the listeners for a tab which are then passed in the generated VDom. The function
* returns a handle that can be used to clean up the listeners
* @param tabbed The tabbed mixin that should be effected when the listeners fire
* @param tab The tab that the listeners are referring to
*/
function setTabListeners(tabbed: TabbedMixin<TabbedChild, TabbedState>, tab: TabbedChild): Handle {
/* TODO: There is an edge case where if a child tab is moved from one tabbed panel to another without being destroyed */
tabListenersMap.set(tab, {
onclickTabListener(evt: MouseEvent): boolean {
evt.preventDefault();
setActiveTab(tabbed, tab);
return true;
},
onclickTabCloseListener(evt: MouseEvent): boolean {
evt.preventDefault();
tab.close().then((result) => {
/* while Maquette schedules a render on DOM events, close happens async, therefore we have to
* invalidate the tabbed when resolved, otherwise the tab panel won't reflect the actual
* children */
if (result) {
tabbed.invalidate();
};
});
return true;
}
});
return {
destroy() {
const tabListeners = tabListenersMap.get(tab);
if (tabListeners) {
tabListenersMap.delete(tab);
}
}
};
}
示例2: Promise
return new Promise((resolve) => {
handlesWeakMap.get(this).forEach((handle) => {
handle && handle.destroy && handle.destroy();
});
handlesWeakMap.delete(this);
this.destroy = noop;
this.own = destroyed;
resolve(true);
});
示例3: setTabListeners
/**
* A utility function that sets the listeners for a tab which are then passed in the generated VDom. The function
* returns a handle that can be used to clean up the listeners
* @param tabbed The tabbed mixin that should be effected when the listeners fire
* @param tab The tab that the listeners are referring to
*/
function setTabListeners(tabbed: TabbedMixin<TabbedChild, TabbedState>, tab: TabbedChild): Handle {
/* TODO: There is an edge case where if a child tab is moved from one tabbed panel to another without being destroyed */
tabListenersMap.set(tab, {
onclickTabListener(evt: MouseEvent): boolean {
evt.preventDefault();
setActiveTab(tabbed, tab);
return true;
},
onclickTabCloseListener(evt: MouseEvent): boolean {
evt.preventDefault();
/* TODO: actually close the tab */
console.log('close');
return;
}
});
return {
destroy() {
const tabListeners = tabListenersMap.get(tab);
if (tabListeners) {
tabListenersMap.delete(tab);
}
}
};
}
示例4: unobserve
}, (err) => { /* error handler */
stateful.emit({
type: 'error',
target: stateful,
error: err
});
unobserve(stateful);
}, () => { /* completed handler */
unobserve(stateful);
}),
handle: {
destroy() {
const observedState = observedStateMap.get(stateful);
if (observedState) {
observedState.subscription.unsubscribe();
observedStateMap.delete(stateful);
}
}
}
};
observedStateMap.set(stateful, observedState);
return observedState.handle;
}
}, (instance: any, options: StatefulOptions<State>) => {
const state = {};
stateWeakMap.set(instance, state);
if (options) {
if (options.state) {
instance.setState(options.state);
}
if (options.id && options.stateFrom) {
示例5: getTabChildVNode
tabbed.children.forEach((tab, key) => {
const isActiveTab = tab === activeTab;
if (isActiveTab || (childrenNodes[key] && childrenNodes[key].properties.classes['visible'])) {
tab.invalidate();
const tabVNode = tab.render();
tabVNode.properties.classes['visible'] = isActiveTab;
childrenNodes[key] = tabVNode;
}
/* else, this tab isn't active and hasn't been previously rendered */
tabs.push(h(tabbed.tagNames.tab, { key: tab, classes: { active: isActiveTab } }, getTabChildVNode(tab)));
});
return [ h(tabbed.tagNames.tabBar, tabs), h('div.panels', childrenNodes) ];
}
}
})
.mixin({
mixin: createDestroyable,
initialize(instance: TabbedMixin<TabbedChild, TabbedState>) {
instance.own({
destroy() {
childrenNodesCache.delete(instance);
}
});
}
}) as TabbedMixinFactory;
export default createTabbedMixin;