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

2.0.69 • 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

263

Version

2.0.69

License

MIT

Unpacked Size

32.2 kB

Total Files

9

Last publish

Collaborators

  • hassellof
  • omboriadmin
  • jaombori