当前位置: 首页>>代码示例>>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;未经允许,请勿转载。