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

TypeScript Promise.resolve函数代码示例

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

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



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

示例1: 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


示例2: 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


示例3:

			return promise.then((action) => {
				return Promise.resolve(action.configure(this._registry)).then(() => action);
			});
开发者ID:digideskio,项目名称:app,代码行数:3,代码来源:createApp.ts


示例4: close

	close(): Promise<boolean>;

	on(type: 'close', listener: EventedListener<CloseEvent>): Handle;
	on(type: string, listener: EventedListener<TargettedEventObject>): Handle;
}

export interface CloseableMixinFactory extends ComposeFactory<Closeable<CloseableState>, StatefulOptions<CloseableState>> { }

const createCloseableMixin: CloseableMixinFactory = createStateful
	.mixin({
		mixin: {
			close(): Promise<boolean> {
				const closeable: Closeable<CloseableState> = this;
				if (closeable.state.closeable) {
					let prevented = false;
					closeable.emit({
						type: 'close',
						target: closeable,
						preventDefault() {
							prevented = true;
						}
					});
					return prevented ? Promise.resolve(false) : closeable.destroy();
				}
				return Promise.resolve(false);
			}
		}
	});

export default createCloseableMixin;
开发者ID:danice,项目名称:widgets,代码行数:30,代码来源:createCloseableMixin.ts


示例5: children

	'option.parent'() {
		let count = 0;
		const parent: ParentMixin<Child> = {
			get children(): List<Child> {
				return;
			},
			append(child: any) {
				assert.strictEqual(child.tagName, 'div');
				child.parent = this;
				count++;
				return { destroy() { } };
			},
			clear() { },
			insert() { return { destroy() { } }; },
			own() { return { destroy() { } }; },
			destroy() { return Promise.resolve(true); },
			emit() { },
			on(): Handle { return { destroy () { } }; }
		};
		const renderable = createRenderable({
			render() {
				return h('h1', [ 'Greetings' ]);
			},
			parent
		});
		assert.strictEqual(renderable.parent, parent);
		assert.strictEqual(count, 1);
	},
	'isRenderable'() {
		const renderable = createRenderable({
			render() {
开发者ID:novemberborn,项目名称:widgets,代码行数:31,代码来源:createRenderable.ts


示例6: createStateful

		'observeState'() {
			const dfd = this.async();
			const stateful = createStateful();
			const observable = {
				observe(id: string): Observable<Object> {
					assert.strictEqual(id, 'foo');
					return new Observable<Object>(function subscribe(observer: Observer<Object>) {
						setTimeout(() => {
							observer.next({ id: 'foo', foo: 'foo' });
							observer.next({ id: 'foo', foo: 'bar' });
							observer.next({ id: 'foo', foo: 'qat' });
						}, 1);
					});
				},
				patch(partial: any, options?: { id?: string }): Promise<Object> {
					return Promise.resolve(partial);
				}
			};

			let count = 0;
			let handle: Handle;

			stateful.on('statechange', (event) => {
				count++;
				if (count === 1) {
					assert.deepEqual(event.target.state, { id: 'foo', foo: 'foo' });
				}
				else if (count === 2) {
					assert.deepEqual(event.target.state, { id: 'foo', foo: 'bar' });
					handle.destroy();
					setTimeout(() => {
开发者ID:benpope82,项目名称:widgets,代码行数:31,代码来源:createStateful.ts


示例7: compose

const idToWidgetMap = new Map<string, Child>();
const widgetToIdMap = new WeakMap<Child, string>();

interface TodoRegistryOptions {
	widgetStore: MemoryStore<Object>;
}

const todoRegistryFactory = compose({
	get(id: string): Promise<Child> {
		let widget: Child = idToWidgetMap.get(id);
		if (!widget) {
			widget = createTodoItem({id, stateFrom: this.widgetStore});
			widgetToIdMap.set(widget, id);
			idToWidgetMap.set(id, widget);
		}
		return Promise.resolve(widget);
	},
	identify(value: Child): string {
		return widgetToIdMap.get(value);
	}
}, function (todoRegistry: any, options: any) {
	if (options) {
		for (let key in options) {
			todoRegistry[key] = options[key];
		}
	}
});

export default todoRegistryFactory;
开发者ID:matt-gadd,项目名称:dojo2-todo-mvc,代码行数:29,代码来源:createTodoRegistry.ts


示例8: function

const noop = function() { return Promise.resolve(false); };
开发者ID:benpope82,项目名称:widgets,代码行数:1,代码来源:createDestroyable.ts


示例9: close

export interface Closeable {
	/**
	 * Attempt to close the widget
	 */
	close(): Promise<boolean>;

	on(type: 'close', listener: EventedListener<CloseEvent>): Handle;
	on(type: string, listener: EventedListener<TargettedEventObject>): Handle;
}

export type CloseableMixin<S extends CloseableState> = Stateful<S> & Closeable;

export interface CloseableMixinFactory extends ComposeFactory<CloseableMixin<CloseableState>, StatefulOptions<CloseableState>> { }

const createCloseableMixin: CloseableMixinFactory = createStateful
	.mixin({
		mixin: {
			close(): Promise<boolean> {
				const closeable: CloseableMixin<CloseableState> = this;
				if (closeable.state.closeable) {
					const event = createCancelableEvent({ type: 'close', target: closeable });
					closeable.emit(event);
					return event.defaultPrevented ? Promise.resolve(false) : closeable.destroy();
				}
				return Promise.resolve(false);
			}
		}
	});

export default createCloseableMixin;
开发者ID:novemberborn,项目名称:widgets,代码行数:30,代码来源:createCloseableMixin.ts



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

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

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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