@phygrid/edge-messaging
v2.0.69
Published
A module performing device-to-module communications for gridapps
Downloads
1,284
Readme
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.