UnetStack supports ParameterChangeNtf which is sent by default when an Agent wants to notify others of a change in parameter value. Most UnetStack Agents send these out on the Topic.PARAMCHANGE topic.
Many applications written around UnetStack want to keep a tab on the values of these parameters and want to get notified when these change. A great example of this would be a UI which shows the location of the node. That's captured by the node.location parameter. Having a mechanism to "watch" this parameter would allow easy integration to reactive Web UI frameworks like Vue.js or React.
So I propose we add on new APIs to allow "watching" parameter changes. But there are a few decisions to be made.
- Where should this API go? UnetSocket object could be a host, but some users of UnetSockets do use a bare fjåge Gateway that's exported by UnetSockets package. Ideally we want this functionality for all.
- Another approach is to create a new subtype
UnetGateway which has this functionality and is used by UnetSocket internally.
- The actual API may be this :
UnetGateway.watch(AgentID agent, String paramName, int index, Function callback) -> handle
handle.unwatch()
- Should we support having a single watcher for all parameters of a single Agent? So something like
UnetGateway.watch(AgentID agent, int index, Function callback)? And also all indexes? Is this complexity better in UnetSocket or in the user of UnetSocket?
- We should also snoop on ALL
ParameterRsp and update any values opportunistically.
Thoughts?
UnetStack supports
ParameterChangeNtfwhich is sent by default when an Agent wants to notify others of a change in parameter value. Most UnetStack Agents send these out on theTopic.PARAMCHANGEtopic.Many applications written around UnetStack want to keep a tab on the values of these parameters and want to get notified when these change. A great example of this would be a UI which shows the location of the node. That's captured by the
node.locationparameter. Having a mechanism to "watch" this parameter would allow easy integration to reactive Web UI frameworks like Vue.js or React.So I propose we add on new APIs to allow "watching" parameter changes. But there are a few decisions to be made.
UnetGatewaywhich has this functionality and is used byUnetSocketinternally.UnetGateway.watch(AgentID agent, String paramName, int index, Function callback) -> handlehandle.unwatch()UnetGateway.watch(AgentID agent, int index, Function callback)? And also all indexes? Is this complexity better in UnetSocket or in the user of UnetSocket?ParameterRspand update any values opportunistically.Thoughts?