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


TypeScript core.Handle类代码示例

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


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

示例1: own

	/**
	 * Register handles for the instance that will be destroyed when `this.destroy` is called
	 *
	 * @param {Handle} handle The handle to add for the instance
	 * @returns {Handle} a handle for the handle, removes the handle for the instance and calls destroy
	 */
	own(handle: Handle): Handle {
		const { handles } = this;
		handles.push(handle);
		return {
			destroy() {
				handles.splice(handles.indexOf(handle));
				handle.destroy();
			}
		};
	}
开发者ID:dylans,项目名称:core,代码行数:16,代码来源:Destroyable.ts

示例2:

	createTimer: (function () {
		let timer: Handle | null;

		return {
			afterEach() {
				timer && timer.destroy();
				timer = null;
			},

			destroy(this: any) {
				const dfd = this.async(1000);
				const spy = sinon.spy();
				timer = util.createTimer(spy, 100);

				setTimeout(function () {
					if (timer) {
						timer.destroy();
					}
				}, 50);

				setTimeout(dfd.callback(function () {
					assert.strictEqual(spy.callCount, 0);
				}), 110);
			},

			timeout(this: any) {
				const dfd = this.async(1000);
				const spy = sinon.spy();
				timer = util.createTimer(spy, 100);

				setTimeout(dfd.callback(function () {
					assert.strictEqual(spy.callCount, 1);
				}), 110);
			}
		};
	})(),
开发者ID:dylans,项目名称:core,代码行数:36,代码来源:util.ts

示例3: run

	/**
	 * Run a suite in a remote browser.
	 */
	run(): Task<any> {
		const remote = this.remote;
		const sessionId = remote.session.sessionId;
		const server = this.executor.server;
		let listenerHandle: Handle;

		return new Task(
			(resolve, reject) => {
				const handleError = (error: InternError) => {
					this.error = error;
					reject(error);
				};

				// This is a deferred that will resolve when the remote sends back a 'remoteConfigured' message
				const pendingConnection = new Deferred<void>();

				// If the remote takes to long to connect, reject the connection promise
				const connectTimer = setTimeout(() => {
					pendingConnection.reject();
				}, this.executor.config.connectTimeout);

				// Subscribe to messages received by the server for a particular remote session ID.
				listenerHandle = server.subscribe(sessionId, (name: keyof RemoteEvents, data: any) => {
					let suite: Suite;

					switch (name) {
						case 'remoteStatus':
							if (data === 'initialized') {
								clearTimeout(connectTimer);
								pendingConnection.resolve();
							}
							break;

						case 'suiteStart':
							suite = data;
							if (!suite.hasParent) {
								// This suite from the browser is a root suite; add its tests to the local suite
								this.tests.push(...suite.tests);

								// Tell the executor that the local suite has started
								return this.executor.emit('suiteStart', this);
							}
							else {
								// If suite from the browser isn't a root (i.e., it's a nested suite), just forward the
								// start event
								return this.executor.emit(name, data);
							}

						case 'suiteEnd':
							suite = data;
							this.skipped = suite.skipped;

							if (!suite.hasParent) {
								// When the remote root suite has finished, replace the local test objects with the
								// incoming test data since it will include final results.
								suite.tests.forEach((test, index) => {
									this.tests[index] = test;
								});

								if (suite.error) {
									handleError(suite.error);
								}
							}
							else {
								// If suite from the browser isn't a root, just forward the end event
								return this.executor.emit(name, data);
							}
							break;

						case 'beforeRun':
						case 'afterRun':
						case 'runStart':
							// Consume these events -- they shouldn't be forwarded to any local listeners
							break;

						case 'runEnd':
							// Consume this event, and do some post-processing
							let promise = remote.setHeartbeatInterval(0);
							if (config.excludeInstrumentation !== true) {
								// get about:blank to always collect code coverage data from the page in case it is
								// navigated away later by some other process; this happens during self-testing when the
								// Leadfoot library takes over
								promise = promise.get('about:blank');
							}
							return promise.then(resolve, reject);

						case 'error':
							handleError(data);
							break;

						default:
							return this.executor.emit(name, data);
					}
				});

				const config = this.executor.config;
				const serverUrlPath = parse(config.serverUrl).pathname;
//.........这里部分代码省略.........
开发者ID:bryanforbes,项目名称:intern,代码行数:101,代码来源:RemoteSuite.ts

示例4:

		).finally(() => {
			listenerHandle.destroy();
			return this.executor.emit('suiteEnd', this);
		});
开发者ID:bryanforbes,项目名称:intern,代码行数:4,代码来源:RemoteSuite.ts

示例5: _dispatch

	protected _dispatch(): void {
		this._isProcessing = true;
		if (this._task) {
			this._task.destroy();
			this._task = null;
		}

		const queue = this._queue;
		let item: QueueItem | undefined;

		while (item = queue.shift()) {
			if (item.isActive && item.callback) {
				item.callback();
			}
		}

		this._isProcessing = false;

		let deferred: QueueItem[] | null = this._deferred;
		if (deferred && deferred.length) {
			this._deferred = null;

			let item: QueueItem | undefined;
			while (item = deferred.shift()) {
				this._schedule(item);
			}
		}
	}
开发者ID:dylans,项目名称:core,代码行数:28,代码来源:Scheduler.ts

示例6: function

	return function () {
		if (handle) {
			handle.destroy();
		}
		return util.cleanup(tunnel);
	};
开发者ID:jason0x43,项目名称:digdug,代码行数:6,代码来源:integration.ts


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