@phygrid/edge-messaging
TypeScript icon, indicating that this package has built-in type declarations

2.0.52 • Public • Published

Phygrid Edge Messaging

A module performing device-to-module communications for gridapps

Hooks

usePublish()

Returns a (type: string, payload: any) => void function, that could be used to broadcast messages to modules.

Example:

import {usePublish} from '@phygrid/edge-messaging';

export default App = () => {
  const publish = usePublish();

  const handleClick = useCallback(() => {
    publish('Test.ping', {hello: 'world'});
  }, [publish])

  return <button onClick={handleClick}>pub</button>
}

useSubscribe(type: string, callback: (msg: any) => void, deps: any[]);

Subscribes to a certain message type.

useStatus(): boolean

Returns message bus connection status

useHeartbeat(): void

Sends heartbeats to GridOS, indicating that app is alive.

Readme

Keywords

none

Package Sidebar

Install

npm i @phygrid/edge-messaging

Weekly Downloads

75

Version

2.0.52

License

MIT

Unpacked Size

32.2 kB

Total Files

9

Last publish

Collaborators

  • hassellof
  • omboriadmin
  • jaombori