• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript WeakMap.get函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了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;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript WeakMap.set函数代码示例发布时间:2022-05-28
下一篇:
TypeScript Symbol.default函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap