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


TypeScript ipcRenderer.once方法代碼示例

本文整理匯總了TypeScript中electron.ipcRenderer.once方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript ipcRenderer.once方法的具體用法?TypeScript ipcRenderer.once怎麽用?TypeScript ipcRenderer.once使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在electron.ipcRenderer的用法示例。


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

示例1: popup

export function popup(items: IContextMenuItem[], options?: IPopupOptions): void {
	const processedItems: IContextMenuItem[] = [];

	const contextMenuId = contextMenuIdPool++;
	const onClickChannel = `vscode:onContextMenu${contextMenuId}`;
	const onClickChannelHandler = (_event: Event, itemId: number, context: IContextMenuEvent) => {
		const item = processedItems[itemId];
		if (item.click) {
			item.click(context);
		}
	};

	ipcRenderer.once(onClickChannel, onClickChannelHandler);
	ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, (_event: Event, closedContextMenuId: number) => {
		if (closedContextMenuId !== contextMenuId) {
			return;
		}

		ipcRenderer.removeListener(onClickChannel, onClickChannelHandler);

		if (options && options.onHide) {
			options.onHide();
		}
	});

	ipcRenderer.send(CONTEXT_MENU_CHANNEL, contextMenuId, items.map(item => createItem(item, processedItems)), onClickChannel, options);
}
開發者ID:DonJayamanne,項目名稱:vscode,代碼行數:27,代碼來源:contextmenu.ts

示例2: popup

export function popup(items: IContextMenuItem[], options?: IPopupOptions): void {
	const processedItems: IContextMenuItem[] = [];

	const onClickChannel = `vscode:onContextMenu${onClickChannelIds++}`;
	const onClickChannelHandler = (event: Event, itemId: number, context: IContextMenuEvent) => processedItems[itemId].click(context);

	ipcRenderer.once(onClickChannel, onClickChannelHandler);
	ipcRenderer.once(CONTEXT_MENU_CLOSE_CHANNEL, () => {
		ipcRenderer.removeListener(onClickChannel, onClickChannelHandler);

		if (options && options.onHide) {
			options.onHide();
		}
	});

	ipcRenderer.send(CONTEXT_MENU_CHANNEL, items.map(item => createItem(item, processedItems)), onClickChannel, options);
}
開發者ID:developers23,項目名稱:vscode,代碼行數:17,代碼來源:contextmenu.ts

示例3: resolve

    return new Promise<boolean>((resolve, reject) => {
      ipcRenderer.once(
        'open-external-result',
        (event: Electron.IpcMessageEvent, { result }: { result: boolean }) => {
          resolve(result)
        }
      )

      ipcRenderer.send('open-external', { path })
    })
開發者ID:ghmoore,項目名稱:desktop,代碼行數:10,代碼來源:app-shell.ts

示例4: Promise

 return new Promise((resolve, reject) => {
   ipcRenderer.send('game:start', {version});
   ipcRenderer.once('game:started', (event, arg) => {
     switch (arg.status) {
       case 'success':
         console.log('running');
         break;
       case 'missing-library':
         // TODO missing library
         console.log(arg.missing);
         const err = new Error('missing-library');
         err['missing'] = arg.missing;
         reject(err);
         break;
       case 'error':
         alert(arg.error);
     }
     resolve();
   });
 })
開發者ID:bangbang93,項目名稱:BMCLJS,代碼行數:20,代碼來源:game.ts

示例5: main

function main(server: Server, initData: ISharedProcessInitData, configuration: ISharedProcessConfiguration): void {
	const services = new ServiceCollection();

	const disposables: IDisposable[] = [];

	const onExit = () => dispose(disposables);
	process.once('exit', onExit);
	ipcRenderer.once('handshake:goodbye', onExit);

	disposables.push(server);

	const environmentService = new EnvironmentService(initData.args, process.execPath);
	const mainRoute = () => TPromise.as('main');
	const logLevelClient = new LogLevelSetterChannelClient(server.getChannel('loglevel', { routeCall: mainRoute, routeEvent: mainRoute }));
	const logService = new FollowerLogService(logLevelClient, createSpdLogService('sharedprocess', initData.logLevel, environmentService.logsPath));
	disposables.push(logService);

	logService.info('main', JSON.stringify(configuration));

	services.set(IEnvironmentService, environmentService);
	services.set(ILogService, logService);
	services.set(IConfigurationService, new SyncDescriptor(ConfigurationService));
	services.set(IRequestService, new SyncDescriptor(RequestService));
	services.set(IDownloadService, new SyncDescriptor(DownloadService));

	const windowsChannel = server.getChannel('windows', { routeCall: mainRoute, routeEvent: mainRoute });
	const windowsService = new WindowsChannelClient(windowsChannel);
	services.set(IWindowsService, windowsService);

	const activeWindowManager = new ActiveWindowManager(windowsService);
	const route = () => activeWindowManager.getActiveClientId();

	const dialogChannel = server.getChannel('dialog', { routeCall: route, routeEvent: route });
	services.set(IDialogService, new DialogChannelClient(dialogChannel));

	const instantiationService = new InstantiationService(services);

	instantiationService.invokeFunction(accessor => {
		const services = new ServiceCollection();
		const environmentService = accessor.get(IEnvironmentService);
		const { appRoot, extensionsPath, extensionDevelopmentLocationURI, isBuilt, installSourcePath } = environmentService;
		const telemetryLogService = new FollowerLogService(logLevelClient, createSpdLogService('telemetry', initData.logLevel, environmentService.logsPath));
		telemetryLogService.info('The below are logs for every telemetry event sent from VS Code once the log level is set to trace.');
		telemetryLogService.info('===========================================================');

		let appInsightsAppender: ITelemetryAppender | null = NullAppender;
		if (!extensionDevelopmentLocationURI && !environmentService.args['disable-telemetry'] && product.enableTelemetry) {
			if (product.aiConfig && product.aiConfig.asimovKey && isBuilt) {
				appInsightsAppender = new AppInsightsAppender(eventPrefix, null, product.aiConfig.asimovKey, telemetryLogService);
				disposables.push(appInsightsAppender); // Ensure the AI appender is disposed so that it flushes remaining data
			}
			const config: ITelemetryServiceConfig = {
				appender: combinedAppender(appInsightsAppender, new LogAppender(logService)),
				commonProperties: resolveCommonProperties(product.commit, pkg.version, configuration.machineId, installSourcePath),
				piiPaths: [appRoot, extensionsPath]
			};

			services.set(ITelemetryService, new SyncDescriptor(TelemetryService, [config]));
		} else {
			services.set(ITelemetryService, NullTelemetryService);
		}
		server.registerChannel('telemetryAppender', new TelemetryAppenderChannel(appInsightsAppender));

		services.set(IExtensionManagementService, new SyncDescriptor(ExtensionManagementService));
		services.set(IExtensionGalleryService, new SyncDescriptor(ExtensionGalleryService));
		services.set(ILocalizationsService, new SyncDescriptor(LocalizationsService));

		const instantiationService2 = instantiationService.createChild(services);

		instantiationService2.invokeFunction(accessor => {
			const extensionManagementService = accessor.get(IExtensionManagementService);
			const channel = new ExtensionManagementChannel(extensionManagementService);
			server.registerChannel('extensions', channel);

			// clean up deprecated extensions
			(extensionManagementService as ExtensionManagementService).removeDeprecatedExtensions();

			const localizationsService = accessor.get(ILocalizationsService);
			const localizationsChannel = new LocalizationsChannel(localizationsService);
			server.registerChannel('localizations', localizationsChannel);

			createSharedProcessContributions(instantiationService2);
			disposables.push(extensionManagementService as ExtensionManagementService);
		});
	});
}
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:86,代碼來源:sharedProcessMain.ts

示例6: c

	return new TPromise<ISharedProcessInitData>((c, e) => {
		ipcRenderer.once('handshake:hey there', (_: any, r: ISharedProcessInitData) => c(r));
		ipcRenderer.send('handshake:hello');
	});
開發者ID:KTXSoftware,項目名稱:KodeStudio,代碼行數:4,代碼來源:sharedProcessMain.ts

示例7: c

	const data = await new Promise<ISharedProcessInitData>(c => {
		ipcRenderer.once('handshake:hey there', (_: any, r: ISharedProcessInitData) => c(r));
		ipcRenderer.send('handshake:hello');
	});
開發者ID:donaldpipowitch,項目名稱:vscode,代碼行數:4,代碼來源:sharedProcessMain.ts

示例8: resolve

const pluginPaths = new Promise<string[]>(resolve => {
    ipc.once('tuitter:plugin-paths', (_: any, paths: string[]) => {
        console.log('Tui: Received plugin paths:', paths);
        resolve(paths);
    });
});
開發者ID:rhysd,項目名稱:Tui,代碼行數:6,代碼來源:index.ts

示例9:

 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program. If not, see http://www.gnu.org/licenses/.
 *
 */

import {IpcMessageEvent, ipcRenderer} from 'electron';
import {EVENT_TYPE} from '../../lib/eventType';

ipcRenderer.once(EVENT_TYPE.ABOUT.LOCALE_RENDER, (event: IpcMessageEvent, labels: string[]) => {
  for (const label in labels) {
    const labelElement = document.querySelector(`[data-string="${label}"]`);
    if (labelElement) {
      labelElement.innerHTML = labels[label];
    }
  }
});

interface Details {
  copyright: string;
  electronVersion: string;
  environment: string;
  productName: string;
  webappVersion: string;
}

ipcRenderer.once(EVENT_TYPE.ABOUT.LOADED, (event: Event, details: Details) => {
  const nameElement = document.getElementById('name');
  if (nameElement) {
開發者ID:wireapp,項目名稱:wire-desktop,代碼行數:32,代碼來源:preload-about.ts


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