当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript WeakMap.get函数代码示例

本文整理汇总了TypeScript中@dojo/shim/WeakMap.get函数的典型用法代码示例。如果您正苦于以下问题:TypeScript get函数的具体用法?TypeScript get怎么用?TypeScript get使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了get函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: beforeProperties

		beforeProperties(function(this: WidgetBase & { own: Function }, properties: any) {
			const injectorItem = this.registry.getInjector<Store<S>>(name);
			if (injectorItem) {
				const { injector } = injectorItem;
				const store = injector();
				const registeredInjectors = registeredInjectorsMap.get(this) || [];
				if (registeredInjectors.length === 0) {
					registeredInjectorsMap.set(this, registeredInjectors);
				}
				if (registeredInjectors.indexOf(injectorItem) === -1) {
					if (paths) {
						const handle = store.onChange(paths.map((path: any) => store.path(path.join('/'))), () =>
							this.invalidate()
						);
						this.own({
							destroy: () => {
								handle.remove();
							}
						});
					} else {
						this.own(
							store.on('invalidate', () => {
								this.invalidate();
							})
						);
					}
					registeredInjectors.push(injectorItem);
				}
				return getProperties(store, properties);
			}
		})(target);
开发者ID:dojo,项目名称:stores,代码行数:31,代码来源:StoreInjector.ts

示例2: Promise

			return new Promise((resolve) => {
				handlesWeakMap.get(this).forEach((handle) => {
					handle && handle.destroy && handle.destroy();
				});
				this.destroy = noop;
				this.own = destroyed;
				resolve(true);
			});
开发者ID:dylans,项目名称:compose,代码行数:8,代码来源:destroyableMixin.ts

示例3: findRouter

export function findRouter(route: Route<Context, Parameters>): Router<Context> {
	while (route.parent) {
		route = route.parent;
	}

	const router = parentMap.get(route);
	if (!router) {
		throw new Error('Cannot generate link for route that is not in the hierarchy');
	}
	else {
		return router;
	}
}
开发者ID:dylans,项目名称:routing,代码行数:13,代码来源:Router.ts

示例4: do

/**
 * A weak map of `do` methods
 */
const doFunctions = new WeakMap<AnyAction, DoFunction<any>>();

/**
 * A weak map of `configure` methods
 */
const configureFunctions = new WeakMap<AnyAction, (configuration: Object) => Promise<void> | void>();

/**
 * A factory which creates instances of Action
 */
const createAction: ActionFactory = compose<ActionMixin<any, DoOptions<any, TargettedEventObject<any>>>, ActionOptions<any, ActionState>>({
		do(this: AnyAction, options?: DoOptions<any, TargettedEventObject<any>>): Task<any> {
			const doFn = doFunctions.get(this);
			if (doFn && this.state.enabled) {
				const result = doFn.call(this, options);
				return isTask(result) ? result : Task.resolve(result);
			}
			return Task.resolve();
		},
		enable(this: AnyAction): void {
			if (!this.state.enabled) {
				this.setState({ enabled: true });
			}
		},
		disable(this: AnyAction): void {
			if (this.state.enabled) {
				this.setState({ enabled: false });
			}
开发者ID:dylans,项目名称:actions,代码行数:31,代码来源:createAction.ts

示例5: return

function getListItems<T>(list: List<T>): T[] {
	return (listItems.get(list) || []) as T[];
}
开发者ID:jason0x43,项目名称:core,代码行数:3,代码来源:List.ts

示例6: parent

	get parent() {
		return parentMap.get(this);
	}
开发者ID:dylans,项目名称:routing,代码行数:3,代码来源:Route.ts

示例7:

function getState<V extends object>(instance: IdentityRegistry<V>): State<V> {
	return privateStateMap.get(instance)!;
}
开发者ID:jason0x43,项目名称:core,代码行数:3,代码来源:IdentityRegistry.ts

示例8: isDestroyable

 * A type guard that determines if the value is a destroyableMixin
 *
 * @param value The value to guard for
 */
export function isDestroyable(value: any): value is Destroyable {
	return Boolean(value && 'destroy' in value && typeof value.destroy === 'function');
}

/**
 * A mixin which adds the concepts of being able to *destroy* handles which the instance
 * *owns*
 */
const destroyableMixin: DestroyableMixin = compose.createMixin()
	.extend('Destroyable', {
		own(this: Destroyable, handle: Handle): Handle {
			const handles = handlesWeakMap.get(this);
			handles.push(handle);
			return {
				destroy() {
					handles.splice(handles.indexOf(handle));
					handle.destroy();
				}
			};
		},

		destroy(this: Destroyable) {
			return new Promise((resolve) => {
				handlesWeakMap.get(this).forEach((handle) => {
					handle && handle.destroy && handle.destroy();
				});
				this.destroy = noop;
开发者ID:dylans,项目名称:compose,代码行数:31,代码来源:destroyableMixin.ts

示例9: state

 * Private map of internal instance state.
 */
const instanceStateMap = new WeakMap<Stateful<State>, State>();

/**
 * State change event type
 */
const stateChangedEventType = 'state:changed';

/**
 * Create an instance of a stateful object
 */
const statefulMixin: StatefulMixin = eventedMixin
	.extend('Stateful', {
		get state(this: Stateful<State>) {
			return instanceStateMap.get(this);
		},
		setState<S extends State>(this: Stateful<S>, value: Partial<S>) {
			const oldState = instanceStateMap.get(this);
			const state = deepAssign({}, oldState, value);
			const eventObject = {
				type: stateChangedEventType,
				state,
				target: this
			};
			instanceStateMap.set(this, state);
			this.emit(eventObject);
		}
	})
	.init((instance: Stateful<State>) => {
		instanceStateMap.set(instance, Object.create(null));
开发者ID:dylans,项目名称:compose,代码行数:31,代码来源:statefulMixin.ts


注:本文中的@dojo/shim/WeakMap.get函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。