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


TypeScript events.on函數代碼示例

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


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

示例1: test

    test('it restores saved highlights', done => {
        const eventBus = new EventEmitter();
        const savedDecorations = [{
            pattern: {
                type: 'string',
                expression: 'PHRASE',
                ignoreCase: false,
                wholeMatch: false
            },
            color: '#F7E4B3'
        }];
        const configStore = mockType<ConfigStore>({savedHighlights: savedDecorations});
        const decorationOperator = mock(DecorationOperator);
        const decorationOperatorFactory = mock(DecorationOperatorFactory);
        when(decorationOperatorFactory.createForVisibleEditors()).thenReturn(decorationOperator);
        new SavedHighlightsRestorer(configStore, decorationOperatorFactory, matchingModeRegistry, eventBus);

        eventBus.on(Event.EXTENSION_READY, () => {
            verify(decorationOperator.addDecoration(new StringPattern({
                phrase: 'PHRASE',
                ignoreCase: false,
                wholeMatch: false
            }), '#F7E4B3'));
            done();
        });

        eventBus.emit(Event.EXTENSION_READY);
    });
開發者ID:ryu1kn,項目名稱:vscode-text-marker,代碼行數:28,代碼來源:saved-highlights-restorer.test.ts

示例2: test

    test('it updates button appearance on receving case sensitivity mode change', done => {
        const eventBus = new EventEmitter();
        const statusBarItem = mockMethods<StatusBarItem>(['show']);
        new ToggleCaseSensitivityModeButton(eventBus, statusBarItem);

        eventBus.on(Event.TOGGLED_CASE_SENSITIVITY, () => {
            assert.deepEqual(statusBarItem.text, 'Aa');
            assert.deepEqual(statusBarItem.tooltip, 'TextMarker: Case Insensitive Mode');
            verify(statusBarItem.show(), {times: 0});
            done();
        });
        eventBus.emit(Event.TOGGLED_CASE_SENSITIVITY, {ignoreCase: true});
    });
開發者ID:ryu1kn,項目名稱:vscode-text-marker,代碼行數:13,代碼來源:toggle-case-sensitivity-mode.test.ts

示例3: Promise

		return new Promise( resolve => {
			// if the lock is free, lock it immediately
			if (!this.locked){
				this.locked = true;
				// console.log('lock acquired');
				return resolve();
			}
			// otherwise sleep the thread and register a callback for when the lock is released
			let reacquire = () => {
				if (!this.locked){
					this.locked = true;
					// console.log('lock acquired');
					this.ee.removeListener('release', reacquire);
					return resolve();
				}
			};
			this.ee.on('release', reacquire);
		});
開發者ID:BelaPlatform,項目名稱:Bela,代碼行數:18,代碼來源:Lock.ts

示例4: function

 node.on = function (event, action) {
   nodeListener.on(event, action);
 };
開發者ID:markrey,項目名稱:node-red-contrib-oracledb,代碼行數:3,代碼來源:oracledb.spec.ts

示例5: switch

handler.on('status', event => {
	const state = event.state;
	switch (state) {
		case 'error':
		case 'failure':
			const commit = event.commit;
			const parent = commit.parents[0];

			// Fetch parent status
			request({
				url: `${parent.url}/statuses`,
				headers: {
					'User-Agent': 'misskey'
				}
			}, (err, res, body) => {
				if (err) {
					console.error(err);
					return;
				}
				const parentStatuses = JSON.parse(body);
				const parentState = parentStatuses[0].state;
				const stillFailed = parentState == 'failure' || parentState == 'error';
				if (stillFailed) {
					post(`**⚠️BUILD STILL FAILED⚠️**: ?[${commit.commit.message}](${commit.html_url})`);
				} else {
					post(`**🚨BUILD FAILED🚨**: →→→?[${commit.commit.message}](${commit.html_url})←←←`);
				}
			});
			break;
	}
});
開發者ID:ha-dai,項目名稱:Misskey,代碼行數:31,代碼來源:github.ts


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