Class: Ipc#
Renderer.Ipc
Hierarchy#
IpcRegistrar
↳ Ipc
Table of contents#
Constructors#
Properties#
Methods#
Constructors#
constructor#
• new Ipc(extension
)
Parameters#
Name | Type |
---|---|
extension |
LensExtension |
Overrides#
IpcRegistrar.constructor
Properties#
[IpcPrefix]#
• Readonly
[IpcPrefix]: string
Inherited from#
IpcRegistrar.__@IpcPrefix@56446
extension#
• Protected
extension: LensExtension
Inherited from#
IpcRegistrar.extension
Methods#
broadcast#
▸ broadcast(channel
, ...args
): void
Parameters#
Name | Type | Description |
---|---|---|
channel |
string |
The channel to broadcast to your whole extension, both main and renderer |
...args |
any [] |
The arguments passed to all listeners |
Returns#
void
Inherited from#
IpcRegistrar.broadcast
invoke#
▸ invoke(channel
, ...args
): Promise
<any
>
Request main to execute its function over the channel
channel.
This function only interacts with functions registered via Ipc.IpcMain.handleRpc
An error will be thrown if no function has been registered on main
with this channel ID.
Parameters#
Name | Type | Description |
---|---|---|
channel |
string |
The channel to invoke a RPC on |
...args |
any [] |
The arguments to pass to the RPC |
Returns#
Promise
<any
>
A promise of the resulting value
listen#
▸ listen(channel
, listener
): Disposer
Listen for broadcasts within your extension.
If the lifetime of the listener should be tied to the mounted lifetime of
a component then putting the returned value in a disposeOnUnmount
call will suffice.
Parameters#
Name | Type | Description |
---|---|---|
channel |
string |
The channel to listen for broadcasts on |
listener |
(event : IpcRendererEvent , ...args : any []) => any |
The function that will be called with the arguments of the broadcast |
Returns#
Disposer
An optional disposer, Lens will cleanup even if this is not called
createInstance#
▸ Static
createInstance<T
, R
>(this
, ...args
): T
Creates the single instance of the child class if one was not already created.
Multiple calls will return the same instance. Essentially throwing away the arguments to the subsequent calls.
Note: this is a racy function, if two (or more) calls are racing to call this function only the first's arguments will be used.
Type parameters#
Name | Type |
---|---|
T |
T |
R |
extends any [] |
Parameters#
Name | Type | Description |
---|---|---|
this |
StaticThis <T , R > |
Implicit argument that is the child class type |
...args |
R |
The constructor arguments for the child class |
Returns#
T
An instance of the child class
Inherited from#
IpcRegistrar.createInstance
getInstance#
▸ Static
getInstance<T
, R
>(this
, strict?
): T
Get the instance of the child class that was previously created.
Type parameters#
Name | Type |
---|---|
T |
T |
R |
extends any [] |
Parameters#
Name | Type | Default value | Description |
---|---|---|---|
this |
StaticThis <T , R > |
undefined |
Implicit argument that is the child class type |
strict |
boolean |
true |
If false will return undefined instead of throwing when an instance doesn't exist. Default: true |
Returns#
T
An instance of the child class
Inherited from#
IpcRegistrar.getInstance
resetInstance#
▸ Static
resetInstance(): void
Delete the instance of the child class.
Note: this doesn't prevent callers of getInstance
from storing the result in a global.
There is no way in JS or TS to prevent globals like that.
Returns#
void
Inherited from#
IpcRegistrar.resetInstance