本文整理汇总了TypeScript中dojo-core/WeakMap.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了get函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: getTabListeners
/**
* Return (or initilize) the tab listeners for a tab
* @param tabbed The tabbed mixin that the listerns refer to
* @param tab The tab that the listeners should be retrieved for
*/
function getTabListeners(tabbed: TabbedMixin<TabbedChild, TabbedState>, tab: TabbedChild): TabListeners {
if (!tabListenersMap.has(tab)) {
/* When the tab is destroyed, it will remove its listeners */
tab.own(setTabListeners(tabbed, tab));
}
return tabListenersMap.get(tab);
}
示例3: setStatefulState
function setStatefulState(stateful: Stateful<State>, value: State) {
const state = deepAssign(stateWeakMap.get(stateful), value);
stateful.emit({
type: 'statechange',
state,
target: stateful
});
return state;
}
示例4: resolve
let registryHandle = actions.get(this).register(id, () => {
const promise = new Promise<void>((resolve) => {
resolve(action.configure(this._registry));
}).then(() => action);
registryHandle.destroy();
registryHandle = actions.get(this).register(id, () => promise);
return promise;
});
示例5: 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);
});
示例6: factory
let registryHandle = widgets.get(this).register(id, () => {
const promise = Promise.resolve().then(() => {
// Always call the factory in a future turn. This harmonizes behavior regardless of whether the
// factory is registered through this method or loaded from a definition.
return factory();
});
registryHandle.destroy();
registryHandle = widgets.get(this).register(id, () => promise);
return promise;
});
示例7: factory
let registryHandle = stores.get(this).register(id, () => {
const promise = Promise.resolve().then(() => {
// Always call the factory in a future turn. This harmonizes behavior regardless of whether the
// factory is registered through this method or loaded from a definition.
return factory();
});
// Replace the registered factory to ensure next time this store is needed, the same store is returned.
registryHandle.destroy();
registryHandle = stores.get(this).register(id, () => promise);
return promise;
});
示例8: 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);
}
}
};
}
示例9: assign
props.classes = classes;
props.styles = projector.styles || {};
if (overrides) {
assign(props, overrides);
}
return props;
},
render(): VNode {
const projector: Projector = this;
const childVNodes: VNode[] = [];
projector.children.forEach((child) => childVNodes.push(child.render()));
return h(projector.tagName || 'div', projector.getNodeAttributes(), childVNodes);
},
attach(append?: boolean): Handle {
const projector: Projector = this;
const projectorData = projectorDataMap.get(projector);
if (projectorData.state === ProjectorState.Attached) {
return projectorData.attachHandle;
}
projectorData.boundRender = projector.render.bind(projector);
/* attaching async, in order to help ensure that if there are any other async behaviours scheduled at the end of the
* turn, they are executed before this, since the attachement is actually done in turn, but subsequent schedule
* renders are done out of turn */
queueTask(() => {
(append ? projectorData.projector.append : projectorData.projector.merge)(projectorData.root, projectorData.boundRender);
});
projectorData.state = ProjectorState.Attached;
projectorData.attachHandle = projector.own({
destroy() {
if (projectorData.state === ProjectorState.Attached) {
projectorData.projector.stop();
示例10: Promise
return new Promise((resolve) => {
resolve(widgets.get(this).get(id)());
});