當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript interfaces.Handle類代碼示例

本文整理匯總了TypeScript中dojo-core/interfaces.Handle的典型用法代碼示例。如果您正苦於以下問題:TypeScript Handle類的具體用法?TypeScript Handle怎麽用?TypeScript Handle使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Handle類的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: function

		'append/remove': function () {
			const dfd = this.async(250);

			let handle: Handle;
			let h1: HTMLElement;

			const callback = function(changes: WatcherRecord[]) {
				changes = changes.filter(value => value.node.nodeType === 1);
				assert.strictEqual(changes.length, 2, 'there should be 2 changes');
				assert.strictEqual(changes[0].type, ChangeType.Added, 'change type should be Added');
				assert.strictEqual(changes[1].type, ChangeType.Removed, 'change type should be Removed');
				assert.strictEqual(changes[0].node, h1);
				handle.destroy();
				dfd.resolve();
			};

			doc.body.innerHTML = '<div></div>';
			h1 = doc.createElement('h1');

			handle = watch(doc.body, callback);
			while (doc.body.lastChild) {
				doc.body.removeChild(doc.body.lastChild);
			}
			doc.body.appendChild(h1);
		},
開發者ID:jdonaghue,項目名稱:parser,代碼行數:25,代碼來源:watch.ts

示例2: function

    'basic': function () {
        const dfd = this.async(250);

        let handle: Handle;
        let div: HTMLDivElement;

        const callback = function (changes: WatcherRecord[]) {
            /* jsdom doesn't create text nodes, but other browsers do, but lets just focus on the nodes we care about */
            changes = changes.filter(function (value: WatcherRecord) {
                return value.node.nodeType === 1;
            });
            assert.equal(changes.length, 3);
            assert.equal(changes[0].type, WatchType.Added);
            assert.equal(changes[1].type, WatchType.Added);
            assert.equal(changes[2].type, WatchType.Added);
            assert.equal(changes[2].node, div);
            handle.destroy();
            doc.body.innerHTML = '';
            dfd.resolve();
        };

        handle = watch(doc.body, callback);
        doc.body.innerHTML = '<div></div><div></div>';
        div = doc.createElement('div');
        doc.body.appendChild(div);
    }
開發者ID:kitsonk,項目名稱:parser,代碼行數:26,代碼來源:watcher.ts

示例3: destroy

		}).then(() => action);
		const registryHandle = actions.get(app).register(id, () => promise);

		return {
			destroy() {
				this.destroy = noop;
				instanceHandle.destroy();
				registryHandle.destroy();
			}
		};
	},

	registerActionFactory(id: Identifier, factory: ActionFactory): Handle {
		const app: App = this;
		let destroyed = false;
		let instanceHandle: Handle;
		let registryHandle = actions.get(app).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(app._registry);
				})
				.then((action) => {
					if (!destroyed) {
						instanceHandle = app._instanceRegistry.addAction(action, id);
					}

					// Configure the action, allow for a promise to be returned.
					return Promise.resolve(action.configure(app._registry)).then(() => {
						return action;
開發者ID:datafordevelopment,項目名稱:dojo-frame,代碼行數:31,代碼來源:createApp.ts

示例4:

			setTimeout(function () {
				handle.destroy();
				doc.body.appendChild(doc.createElement('div'));
			}, 200);
開發者ID:jdonaghue,項目名稱:parser,代碼行數:4,代碼來源:watch.ts


注:本文中的dojo-core/interfaces.Handle類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。