Class: PortDetector
portDetector.PortDetector
Port Detector
It provides port detection and client/server port switching functions.
Constructors
constructor
• new PortDetector(sharedAppOptions
, lastAction
)
Parameters
Name | Type |
---|---|
sharedAppOptions | ISharedAppOptions |
lastAction | ReactantLastAction |
Defined in
packages/reactant-share/src/portDetector.ts:63
Properties
clientCallbacks
• Protected
clientCallbacks: Set
<CallbackWithHook
<Transport
<ServerTransport
, ClientTransport
>>>
Defined in
packages/reactant-share/src/portDetector.ts:40
clientId
• clientId: null
| string
= null
client id
Defined in
packages/reactant-share/src/portDetector.ts:56
lastAction
• lastAction: ReactantLastAction
Defined in
packages/reactant-share/src/portDetector.ts:65
lastHooks
• Protected
Optional
lastHooks: Set
<void
| () => void
>
Defined in
packages/reactant-share/src/portDetector.ts:34
portApp
• Protected
Optional
portApp: Partial
<Record
<Port
, App
<any
, any
, any
>>>
Defined in
packages/reactant-share/src/portDetector.ts:32
previousPort
• Optional
previousPort: Port
previous port
Defined in
packages/reactant-share/src/portDetector.ts:51
serverCallbacks
• Protected
serverCallbacks: Set
<CallbackWithHook
<Transport
<ServerTransport
, ClientTransport
>>>
Defined in
packages/reactant-share/src/portDetector.ts:36
sharedAppOptions
• sharedAppOptions: ISharedAppOptions
Defined in
packages/reactant-share/src/portDetector.ts:64
syncFullStatePromise
• Optional
syncFullStatePromise: Promise
<undefined
| null
| Record
<string
, any
>>
Defined in
packages/reactant-share/src/portDetector.ts:44
transport
• Optional
transport: Transport
<any
, any
>
Defined in
packages/reactant-share/src/portDetector.ts:208
Accessors
disableSyncClient
• get
disableSyncClient(): boolean
Returns
boolean
Defined in
packages/reactant-share/src/portDetector.ts:114
id
• get
id(): string
Returns
string
Defined in
packages/reactant-share/src/portDetector.ts:102
isClient
• get
isClient(): boolean
Returns
boolean
Defined in
packages/reactant-share/src/portDetector.ts:200
isServer
• get
isServer(): boolean
Returns
boolean
Defined in
packages/reactant-share/src/portDetector.ts:196
isServerWorker
• get
isServerWorker(): boolean
Returns
boolean
Defined in
packages/reactant-share/src/portDetector.ts:192
isWorkerMode
• get
isWorkerMode(): boolean
Returns
boolean
Defined in
packages/reactant-share/src/portDetector.ts:188
name
• get
name(): string
Returns
string
Defined in
packages/reactant-share/src/portDetector.ts:110
shared
• get
shared(): boolean
Returns
boolean
Defined in
packages/reactant-share/src/portDetector.ts:106
transports
• get
transports(): Transports
Returns
Transports
Defined in
packages/reactant-share/src/portDetector.ts:204
Methods
allowDisableSync
▸ allowDisableSync(): boolean
allow Disable Sync
Returns
boolean
Defined in
packages/reactant-share/src/portDetector.ts:61
detectPort
▸ Protected
detectPort(port
): undefined
| App
<any
, any
, any
>
Parameters
Name | Type |
---|---|
port | Port |
Returns
undefined
| App
<any
, any
, any
>
Defined in
packages/reactant-share/src/portDetector.ts:122
onClient
▸ onClient(callback
): () => void
onClient
When the port is client, this hook will execute. And allow to return a function that will be executed when the current port is switched to server.
Parameters
Name | Type |
---|---|
callback | CallbackWithHook <Transport <ClientTransport , ServerTransport >> |
Returns
fn
▸ (): void
Returns
void
Defined in
packages/reactant-share/src/portDetector.ts:163
onServer
▸ onServer(callback
): () => void
onServer
When the port is server, this hook will execute. And allow to return a function that will be executed when the current port is switched to client.
Parameters
Name | Type |
---|---|
callback | CallbackWithHook <Transport <ServerTransport , ClientTransport >> |
Returns
fn
▸ (): void
Returns
void
Defined in
packages/reactant-share/src/portDetector.ts:132
setPort
▸ setPort(currentPortApp
, transport
): void
Parameters
Name | Type |
---|---|
currentPortApp | Partial <Record <Port , App <any , any , any >>> |
transport | Transport <ServerTransport , ClientTransport > | Transport <ClientTransport , ServerTransport > |
Returns
void
Defined in
packages/reactant-share/src/portDetector.ts:210
syncFullState
▸ syncFullState(__namedParameters?
): Promise
<void
>
Parameters
Name | Type |
---|---|
__namedParameters | Object |
__namedParameters.forceSync | undefined | boolean |
Returns
Promise
<void
>
Defined in
packages/reactant-share/src/portDetector.ts:253
syncToClients
▸ syncToClients(): void
Returns
void
Defined in
packages/reactant-share/src/portDetector.ts:239
transform
▸ transform(port
, transport?
): void
transform port with new transport
Parameters
Name | Type |
---|---|
port | Port |
transport? | Transport <any , any > |
Returns
void