Watches

Watches

Overview

Watches are a mechanism used to subscribe to real-time changes made to a set of records in the Folio database. Watches are patterned on oBIX/Haystack watches which are designed around polling-for-changes. Polling provides the foundation for simple but robust networking. And by only polling for values which have changed, we can keep payloads very small. This in turn allows us to efficiently poll several times a second.

Axon APIs

The following Axon functions are used to work with watches:

  • watchOpen()

  • watchPoll()

  • watchAdd()

  • watchRemove()

  • watchClose()

Example code:

// read all points under specific connector and put into watch, // the second parameter to watchOpen is debug string to // indicate who is opening the watch grid: readAll(point and fooConnRef==xxxx).watchOpen("My Custom App") // grid is now the result of my readAll operation, plus it // contains my watch id to use for polling watchId: grid.meta->watchId // now enter a loop to poll for any changes to my original points changes: watchPoll(watchId) // when done we should gracefully close the watch, or it will // close automatically if we fail to poll and its lease expires watchClose(watchId)