Class: IpcRenderer#
Hierarchy#
- IpcRegistrar
↳ IpcRenderer
Index#
Constructors#
Properties#
Methods#
Constructors#
constructor#
+ new IpcRenderer(extension: LensRendererExtension): IpcRenderer
Overrides void
Defined in src/extensions/ipc/ipc-renderer.ts:28
Parameters:
| Name | Type |
|---|---|
extension |
LensRendererExtension |
Returns: IpcRenderer
Properties#
[IpcPrefix]#
• [IpcPrefix]: string
Inherited from IpcRenderer.[IpcPrefix]
Defined in src/extensions/ipc/ipc-registrar.ts:29
Protected extension#
• extension: LensExtension
Inherited from IpcRenderer.extension
Defined in src/extensions/ipc/ipc-registrar.ts:31
Methods#
broadcast#
▸ broadcast(channel: string, ...args: any[]): void
Inherited from IpcRenderer.broadcast
Defined in src/extensions/ipc/ipc-registrar.ts:41
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
invoke#
▸ invoke(channel: string, ...args: any[]): Promise‹any›
Defined in src/extensions/ipc/ipc-renderer.ts:60
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: string, listener: function): Disposer
Defined in src/extensions/ipc/ipc-renderer.ts:42
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:
▪ channel: string
The channel to listen for broadcasts on
▪ listener: function
The function that will be called with the arguments of the broadcast
▸ (event: IpcRendererEvent, ...args: any[]): any
Parameters:
| Name | Type |
|---|---|
event |
IpcRendererEvent |
...args |
any[] |
Returns: Disposer
An optional disposer, Lens will cleanup even if this is not called
Static createInstance#
▸ createInstance‹T, R›(this: StaticThis‹T, R›, ...args: R): T
Inherited from ExtensionStore.createInstance
Defined in src/common/utils/singleton.ts:46
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:
▪ T
▪ R: 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
Static getInstance#
▸ getInstance‹T, R›(this: StaticThis‹T, R›, strict: boolean): T | undefined
Inherited from ExtensionStore.getInstance
Defined in src/common/utils/singleton.ts:67
Get the instance of the child class that was previously created.
Type parameters:
▪ T
▪ R: any[]
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
this |
StaticThis‹T, R› | - | 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 | undefined
An instance of the child class
Static resetInstance#
▸ resetInstance(): void
Inherited from ExtensionStore.resetInstance
Defined in src/common/utils/singleton.ts:82
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