當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript WeakMap.get函數代碼示例

本文整理匯總了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);
			}
		}
	};
}
開發者ID:danice,項目名稱:widgets,代碼行數:36,代碼來源:createTabbedMixin.ts

示例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);
}
開發者ID:benpope82,項目名稱:widgets,代碼行數:12,代碼來源:createTabbedMixin.ts

示例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;
}
開發者ID:benpope82,項目名稱:widgets,代碼行數:9,代碼來源:createStateful.ts

示例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;
		});
開發者ID:digideskio,項目名稱:app,代碼行數:9,代碼來源:createApp.ts

示例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);
		});
開發者ID:benpope82,項目名稱:widgets,代碼行數:9,代碼來源:createDestroyable.ts

示例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;
		});
開發者ID:dylans,項目名稱:app,代碼行數:10,代碼來源:createApp.ts

示例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;
		});
開發者ID:digideskio,項目名稱:app,代碼行數:11,代碼來源:createApp.ts

示例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);
			}
		}
	};
}
開發者ID:benpope82,項目名稱:widgets,代碼行數:30,代碼來源:createTabbedMixin.ts

示例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();
開發者ID:kitsonk,項目名稱:widgets,代碼行數:31,代碼來源:projector.ts

示例10: Promise

			return new Promise((resolve) => {
				resolve(widgets.get(this).get(id)());
			});
開發者ID:digideskio,項目名稱:app,代碼行數:3,代碼來源:createApp.ts


注:本文中的dojo-core/WeakMap.get函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。