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


TypeScript WeakMap.set函數代碼示例

本文整理匯總了TypeScript中dojo-shim/WeakMap.set函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript set函數的具體用法?TypeScript set怎麽用?TypeScript set使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了set函數的10個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: initialize

			privateState.browserLocation.replace(pathname + search + this.prefix(path));

			this.emit({
				type: 'change',
				value: path
			});
		}
	},
	initialize(instance: HashHistory, { window }: HashHistoryOptions = { window: global }) {
		const { location: browserLocation } = window;

		const privateState: PrivateState = {
			current: browserLocation.hash.slice(1),
			browserLocation
		};
		privateStateMap.set(instance, privateState);

		instance.own(on(window, 'hashchange', () => {
			const path = browserLocation.hash.slice(1);

			// Ignore hashchange for the current path. Guards against browsers firing hashchange when the history
			// manager sets the hash.
			if (path !== privateState.current) {
				privateState.current = path;
				instance.emit({
					type: 'change',
					value: path
				});
			}
		}));
	}
開發者ID:jdonaghue,項目名稱:routing,代碼行數:31,代碼來源:createHashHistory.ts

示例2: function

			around: {
				renderPlotPoints<G, T>(renderColumns: (points: ColumnPoint<T>[]) => VNode[]) {
					return function(this: any, stackPoints: StackedColumnPoint<G, T>[]) {
						return stackPoints.map(({ columnPoints, datum }) => {
							const props: VNodeProperties = {
								key: datum.input
							};
							return h('g', props, renderColumns.call(this, columnPoints));
						});
					};
				}
			}
		},

		initialize<G, T>(
			instance: StackedColumnChart<G, T, StackedColumn<G, T>, StackedColumnChartState<T>>,
			{
				stackSelector
			}: StackedColumnChartOptions<G, T, StackedColumn<G, T>, StackedColumnChartState<T>> = {}
		) {
			if (!stackSelector) {
				// Ignore instance.stackSelector being undefined, let the runtime throw an exception instead.
				stackSelector = (input: T) => instance.stackSelector!(input);
			}

			privateStateMap.set(instance, { stackSelector });
		}
	});

export default createStackedColumnChart;
開發者ID:novemberborn,項目名稱:dojo2-dataviz,代碼行數:30,代碼來源:createStackedColumnChart.ts

示例3: setStatefulState

				};
				const subscription = observable
					.observe(id)
					.subscribe(
						(state) => {
							setStatefulState(stateful, state);
						},
						(err) => {
							throw err;
						},
						() => {
							completeStatefulState(stateful);
						}
					);

				observedStateMap.set(stateful, { id, observable, subscription, handle });
				return handle;
			}
		},
		initialize(instance: StatefulMixin<State> & Evented, options: StatefulOptions<State>) {
			stateWeakMap.set(instance, Object.create(null));
			instance.own({
				destroy() {
					stateWeakMap.delete(instance);
				}
			});
			if (options) {
				const { id, stateFrom, state } = options;
				if (typeof id !== 'undefined' && stateFrom) {
					instance.own(instance.observeState(id, stateFrom));
				}
開發者ID:jdonaghue,項目名稱:compose,代碼行數:31,代碼來源:createStateful.ts

示例4: prefix

			return privateStateMap.get(this).current;
		},

		prefix(path: string) {
			return path;
		},

		set(this: MemoryHistory, path: string) {
			const privateState = privateStateMap.get(this);
			if (privateState.current === path) {
				return;
			}

			privateState.current = path;
			this.emit({
				type: 'change',
				value: path
			});
		},

		replace(this: MemoryHistory, path: string) {
			this.set(path);
		}
	},
	initialize(instance: MemoryHistory, { path: current }: MemoryHistoryOptions = { path: '' }) {
		privateStateMap.set(instance, { current });
	}
});

export default createMemoryHistory;
開發者ID:jdonaghue,項目名稱:routing,代碼行數:30,代碼來源:createMemoryHistory.ts

示例5: getNodeAttributes

	.mixin({
		mixin: createFormFieldMixin,
		aspectAdvice: {
			before: {
				getNodeAttributes(overrides: VNodeProperties = {}) {
					const focusableTextInput: FocusableTextInput = this;

					overrides.afterUpdate = afterUpdateFunctions.get(focusableTextInput);

					if (focusableTextInput.state.placeholder !== undefined) {
						overrides.placeholder = focusableTextInput.state.placeholder;
					}

					return [overrides];
				}
			}
		},
		initialize(instance) {
			instance.own(instance.on('input', (event: TypedTargetEvent<HTMLInputElement>) => {
				instance.value = event.target.value;
			}));
			afterUpdateFunctions.set(instance, (element: HTMLInputElement) => afterUpdate(instance, element));
		}
	})
	.extend({
		type: 'text',
		tagName: 'input'
	});

export default createFocusableTextInput;
開發者ID:matt-gadd,項目名稱:examples,代碼行數:30,代碼來源:createFocusableTextInput.ts

示例6: makeMidResolver

			hasWidget: instance.hasWidget.bind(instance),
			identifyWidget: instance.identifyWidget.bind(instance)
		};
		Object.freeze(instance._registry);

		instance._resolveMid = makeMidResolver(toAbsMid);

		Object.defineProperty(instance, 'defaultStore', {
			configurable: false,
			enumerable: true,
			value: defaultStore,
			writable: false
		});

		Object.defineProperty(instance, 'registryProvider', {
			configurable: false,
			enumerable: true,
			value: new RegistryProvider(instance._registry),
			writable: false
		});

		actions.set(instance, new IdentityRegistry<RegisteredFactory<ActionLike>>());
		customElementFactories.set(instance, new IdentityRegistry<RegisteredFactory<WidgetLike>>());
		customElementInstances.set(instance, new IdentityRegistry<WidgetLike>());
		stores.set(instance, new IdentityRegistry<RegisteredFactory<StoreLike>>());
		widgets.set(instance, new IdentityRegistry<RegisteredFactory<WidgetLike>>());
	}
}) as AppFactory;

export default createApp;
開發者ID:datafordevelopment,項目名稱:dojo-frame,代碼行數:30,代碼來源:createApp.ts

示例7:

}, (instance) => {
	handlesWeakMap.set(instance, []);
});
開發者ID:jdonaghue,項目名稱:compose,代碼行數:3,代碼來源:createDestroyable.ts

示例8: unobserve

							(err) => {
								/* TODO: Should we emit an error, instead of throwing? */
								throw err;
							}, /* error handler */
							() => unobserve(stateful)), /* completed handler */
					handle: {
						destroy() {
							const observedState = observedStateMap.get(stateful);
							if (observedState) {
								observedState.subscription.unsubscribe();
								observedStateMap.delete(stateful);
							}
						}
					}
				};
				observedStateMap.set(stateful, observedState);
				return observedState.handle;
			}
		},
		initialize(instance: StatefulMixin<State> & Evented, options: StatefulOptions<State>) {
			/* Using Object.create(null) will improve performance when looking up properties in state */
			stateWeakMap.set(instance, Object.create(null));
			instance.own({
				destroy() {
					stateWeakMap.delete(instance);
				}
			});
			if (options) {
				const { id, stateFrom, state } = options;
				if (typeof id !== 'undefined' && stateFrom) {
					instance.own(instance.observeState(id, stateFrom));
開發者ID:jdonaghue,項目名稱:compose,代碼行數:31,代碼來源:createStateful.ts

示例9: function

			around: {
				renderPlotPoints<G, T>(renderColumns: (points: ColumnPoint<T>[]) => VNode[]) {
					return function(this: any, groupPoints: GroupedColumnPoint<G, T>[]) {
						return groupPoints.map(({ columnPoints, datum }) => {
							const props: VNodeProperties = {
								key: datum.input
							};
							return h('g', props, renderColumns.call(this, columnPoints));
						});
					};
				}
			}
		},

		initialize<G, T>(
			instance: GroupedColumnChart<G, T, GroupedColumn<G, T>, GroupedColumnChartState<T>>,
			{
				groupSelector
			}: GroupedColumnChartOptions<G, T, GroupedColumn<G, T>, GroupedColumnChartState<T>> = {}
		) {
			if (!groupSelector) {
				// Ignore instance.groupSelector being undefined, let the runtime throw an exception instead.
				groupSelector = (input: T) => instance.groupSelector!(input);
			}

			privateStateMap.set(instance, { groupSelector });
		}
	});

export default createGroupedColumnChart;
開發者ID:novemberborn,項目名稱:dojo2-dataviz,代碼行數:30,代碼來源:createGroupedColumnChart.ts

示例10: if

			contextFactory = context;
		}
		else if (typeof context === 'undefined') {
			contextFactory = () => {
				return {} as C;
			};
		}
		else {
			// Assign to a constant since the context variable may be changed after the function is defined,
			// which would violate its typing.
			const sharedContext = context;
			contextFactory = () => sharedContext;
		}

		if (history) {
			instance.own(history);
		}

		privateStateMap.set(instance, {
			contextFactory,
			currentSelection: [],
			dispatchFromStart: false,
			fallback,
			history,
			routes: []
		});
	}
});

export default createRouter;
開發者ID:jdonaghue,項目名稱:routing,代碼行數:30,代碼來源:createRouter.ts


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