Contents

Ipc

Provides Inter-Process Communication (IPC) capabilities between the renderer and main processes.

import { ipc } from '@mobrowser/api';

Example 

import { ipc } from '@mobrowser/api';
import { GreetService } from './gen/ipc_service';

const greetService = GreetService({
  async SayHello(request) {
    return { value: `Hello, ${request.name}!` }
  },
})
ipc.registerService(greetService)

Methods 

registerService() 

registerService(service: ServiceInstance): void;

Registers a protobuf RPC service. The service must be created by a generated factory function (e.g., GreetService(impl)) that attaches the service descriptor.

ParameterTypeDescription
serviceServiceInstanceThe service instance created by a generated factory function.

unregisterService() 

unregisterService(service: ServiceInstance): void;

Unregisters a previously registered protobuf RPC service, removing all of its method handlers.

@link registerService}.

ParameterTypeDescription
serviceServiceInstanceThe service instance previously passed to {@link registerService}.