本文整理汇总了TypeScript中dojo-core/WeakMap.set函数的典型用法代码示例。如果您正苦于以下问题:TypeScript set函数的具体用法?TypeScript set怎么用?TypeScript set使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了set函数的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);
}
}
};
}
开发者ID:danice,项目名称:widgets,代码行数:36,代码来源:createTabbedMixin.ts
示例2: if
}, (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) {
instance.own(instance.observeState(options.id, options.stateFrom));
}
else if (options.id || options.stateFrom) {
throw new TypeError('Factory requires options "id" and "stateFrom" to be supplied together.');
}
}
})
开发者ID:benpope82,项目名称:widgets,代码行数:15,代码来源:createStateful.ts
示例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);
}
}
};
}
开发者ID:benpope82,项目名称:widgets,代码行数:30,代码来源:createTabbedMixin.ts
示例4: state
return projectorData && projectorData.root && projectorData.root.ownerDocument;
},
get state(): ProjectorState {
const projectorData = projectorDataMap.get(this);
return projectorData && projectorData.state;
}
})
.mixin({
mixin: createParentMixin,
initialize(instance: Projector, options: ProjectorOptions) {
const projector = createMaquetteProjector({});
const root = options && options.root || document.body;
projectorDataMap.set(instance, {
projector,
root,
state: ProjectorState.Detached
});
if (options && options.autoAttach) {
instance.attach(options && options.append);
}
},
aspectAdvice: {
after: {
clear(): void {
const projector: Projector = this;
projector.invalidate();
}
}
}
})
开发者ID:kitsonk,项目名称:widgets,代码行数:31,代码来源:projector.ts
示例5: hasWidget
},
hasWidget(id: Identifier): boolean {
return widgets.get(this).hasId(id);
}
},
initialize (instance: App, { toAbsMid = (moduleId: string) => moduleId }: AppOptions = {}) {
instance._registry = {
getAction: instance.getAction.bind(instance),
hasAction: instance.hasAction.bind(instance),
getCustomElementFactory: instance.getCustomElementFactory.bind(instance),
hasCustomElementFactory: instance.hasCustomElementFactory.bind(instance),
getStore: instance.getStore.bind(instance),
hasStore: instance.hasStore.bind(instance),
getWidget: instance.getWidget.bind(instance),
hasWidget: instance.hasWidget.bind(instance)
};
Object.freeze(instance._registry);
instance._resolveMid = makeMidResolver(toAbsMid);
actions.set(instance, new IdentityRegistry<RegisteredFactory<ActionLike>>());
customElements.set(instance, new IdentityRegistry<RegisteredFactory<WidgetLike>>());
stores.set(instance, new IdentityRegistry<RegisteredFactory<StoreLike>>());
widgets.set(instance, new IdentityRegistry<RegisteredFactory<WidgetLike>>());
}
}) as AppFactory;
export default createApp;
开发者ID:digideskio,项目名称:app,代码行数:30,代码来源:createApp.ts
示例6: unobserve
});
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) {
instance.own(instance.observeState(options.id, options.stateFrom));
}
else if (options.id || options.stateFrom) {
throw new TypeError('Factory requires options "id" and "stateFrom" to be supplied together.');
}
开发者ID:benpope82,项目名称:widgets,代码行数:31,代码来源:createStateful.ts
示例7: Array
if (tab.state.closeable) {
nodes.push(h('div.tab-close', { onclick: tabListeners.onclickTabCloseListener }, [ 'X' ]));
}
return nodes;
}
/* We need to generate a set of VDom the represents the buttons */
/* TODO: Allow the location of the tab bar to be set (top/left/bottom/right) */
const tabs: VNode[] = [];
let childrenNodes = childrenNodesCache.get(tabbed);
/* Best to discard the childrenNodes array if the sizes don't match, otherwise
* we can get some vdom generation issues when adding or removing tabs */
if (!childrenNodes || childrenNodes.length !== tabbed.children.size) {
childrenNodes = Array(tabbed.children.size);
childrenNodesCache.set(tabbed, childrenNodes);
}
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)));
});
开发者ID:danice,项目名称:widgets,代码行数:30,代码来源:createTabbedMixin.ts
示例8: compose
import compose from 'dojo-compose/compose';
import { MemoryStore } from 'dojo-widgets/util/createMemoryStore';
const idToWidgetMap = new Map<string, Child>();
const widgetToIdMap = new WeakMap<Child, string>();
interface TodoRegistryOptions {
widgetStore: MemoryStore<Object>;
}
const todoRegistryFactory = compose({
get(id: string): Promise<Child> {
let widget: Child = idToWidgetMap.get(id);
if (!widget) {
widget = createTodoItem({id, stateFrom: this.widgetStore});
widgetToIdMap.set(widget, id);
idToWidgetMap.set(id, widget);
}
return Promise.resolve(widget);
},
identify(value: Child): string {
return widgetToIdMap.get(value);
}
}, function (todoRegistry: any, options: any) {
if (options) {
for (let key in options) {
todoRegistry[key] = options[key];
}
}
});
开发者ID:matt-gadd,项目名称:dojo2-todo-mvc,代码行数:30,代码来源:createTodoRegistry.ts
示例9:
}, (instance) => {
handlesWeakMap.set(instance, []);
});
开发者ID:benpope82,项目名称:widgets,代码行数:3,代码来源:createDestroyable.ts
示例10: getNodeAttributes
}
}
const createFocusableTextInput: FocusableTextInputFactory = createTextInput
.mixin({
mixin: createFormFieldMixin,
aspectAdvice: {
before: {
getNodeAttributes(overrides: VNodeProperties = {}) {
const focusableTextInput: FocusableTextInput = this;
overrides.afterUpdate = afterUpdateFunctions.get(focusableTextInput);
return [overrides];
}
}
},
initialize(instance) {
instance.own(instance.on('input', (event: TypedTargetEvent<HTMLInputElement>) => {
instance.value = event.target.value;
}));
afterUpdateFunctions.set(instance, (element: any) => afterUpdate(instance, element));
}
})
.extend({
type: 'text',
tagName: 'input'
});
export default createFocusableTextInput;
开发者ID:matt-gadd,项目名称:dojo2-todo-mvc,代码行数:30,代码来源:createFocusableTextInput.ts
注:本文中的dojo-core/WeakMap.set函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论