Class: Ipc#
Main.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
handle#
▸ handle(channel
, handler
): void
Declare a RPC over channel
. Lens will cleanup when the extension is disabled or uninstalled
Parameters#
Name | Type | Description |
---|---|---|
channel |
string |
The name of the RPC |
handler |
(event : IpcMainInvokeEvent , ...args : any []) => any |
The remote procedure that is called |
Returns#
void
listen#
▸ listen(channel
, listener
): Disposer
Listen for broadcasts within your extension
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 when the extension is disabled or uninstalled 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