3.2.0 • Published 1 year ago

@jaraxa/nc-wsclient v3.2.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year ago

ws-client

ws-client

Description

  • Netcomposer WebSocket wrapper using react-use-websocket and the Event Bus design pattern
  • Provides connection, communication and event subscription

WS Communication

WS communication

Dependencies

API

  • WSClientProvider: provider that allows the use of the useWSClient hook. Params: wsUrl (WS url to connect to), netcomposerAppPrefix (app identifier used as prefix), logMode ('verbose', 'minimalist', 'only-error' or 'off'), keepAliveTimeout (max time that the client can be idle to keep alive the connection with the server. Optional, defaults to 5 seconds), ackTimeout (max time to consider a WS ack message as slow. Optional, defaults to 5 seconds) & resultTimeout (max time to consider a WS result message as slow. Optional, defaults to 10 seconds). Client code must be wrapped by it.
  • useWSClient: hook that give access through destructuring to connectionStatus, sendCommand, connect & disconnect.
    • connectionStatus: variable that provides the state of the WS connection. One of Connecting, Open, Closing, Closed or Uninstantiated. Type can be imported as ConnectionStatus.
    • sendCommand: function that allows message sending to the WS. Accepts a param of type Message and returns a Promise. Message type can be imported.
  • useEventSubscription: hook that provides a subscribe on mount and unsubscribe on unmount mechanism. Params: eventKey (the event key this subscription is associated to) & eventHandler (the eventHandler to call in response to that event).

important: useEventSubscription eventHandler must be wrapped in React.useCallback to maintain referential stability

Log Modes

Verbose

  • Ack
  • Ping
  • Command
  • Result
  • Event
  • Error

Minimalist

  • Command
  • Result
  • Event
  • Error

Only Error

  • Result Error
  • Error

Off

  • Nothing

Examples

TODO

Resources

3.2.0

1 year ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

1 year ago

3.1.7

1 year ago

3.1.6

1 year ago

3.1.5

1 year ago

3.1.4

1 year ago

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

1 year ago

3.0.5

1 year ago

3.0.1

2 years ago

3.0.0

2 years ago

2.8.6

2 years ago

2.8.3

2 years ago

2.8.2

2 years ago

2.8.5

2 years ago

2.8.4

2 years ago

2.8.1

2 years ago

2.8.0

2 years ago

2.7.2

2 years ago

2.7.1

2 years ago

2.7.4

2 years ago

2.7.3

2 years ago

1.10.2

2 years ago

1.9.0

2 years ago

1.8.0

2 years ago

1.7.0

2 years ago

2.3.0

2 years ago

2.2.0

2 years ago

2.0.2

2 years ago

2.5.0

2 years ago

2.4.1

2 years ago

2.4.0

2 years ago

2.3.1

2 years ago

2.7.0

2 years ago

2.6.1

2 years ago

2.4.3

2 years ago

2.6.0

2 years ago

2.5.1

2 years ago

2.4.2

2 years ago

2.6.3

2 years ago

2.6.2

2 years ago

2.1.0

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

2.6.5

2 years ago

2.6.4

2 years ago

2.6.6

2 years ago

1.10.1

2 years ago

1.10.0

2 years ago

1.6.2

2 years ago

1.6.1

2 years ago

1.6.0

2 years ago

1.5.0

2 years ago

1.4.0

2 years ago

1.3.2

2 years ago

1.3.1

2 years ago

1.3.0

2 years ago

1.2.0

2 years ago

1.1.0

2 years ago

1.0.0

2 years ago