Constructs a new watch.
Please note, all watches must be closed when no longer used.
A client side display name for the watch.
The watch will observe this subject.
An empty grid to use for the watch.
console.log(watch.display)
The display name of the watch.
the ids as refs of the records that in error and can't be watched on the server.
The ids of the records that are in error and can't be watched on the server.
Returns the poll rate in seconds.
const pollRate = watch.pollRate
The poll rate for this watch.
Attempt to set a new poll rate in seconds for the watch.
Please note, this value may be ignored.
// Set the poll rate to 10 seconds.
watch.pollRate = 10
The poll rate.
Static
watchesBuilds a changed callback handler based upon the parameters.
Please note, the returned callback should be used to unregister the callback handler from the watch.
// Add event handlers. We're only interested in 'curVal' changes.
watch.changed({
interests: ['curVal'],
callback: (event) => console.log(event)
})
...
// Add event handlers. We're only interested in changes to curVal when it's above
// a certain value.
watch.changed({
interests: ['curVal'],
condition: 'curVal > 50°F',
callback: event => console.log(event),
})
The built callback handler.
Fire an event callback.
The event object.
The emitter instance.
Return the callbacks for the event type or all callbacks if the event type is not specified.
const anArrayOfCallbacks = watch.getCallbacks()
Optional
eventType: WatchEventTypeOptional event type.
The callbacks.
Return true if there are callback handlers for the specified event type.
If there event type is not specified then check to see if there are any callback handlers.
if (watch.hasCallbacks()) {
// Do something...
}
Optional
eventType: WatchEventTypeTrue if there are callbacks.
Remove an event handler from a watch.
watch.off(WatchEventType.Changed, cb)
event type to remove.
callback to remove.
The emitter instance.
Add an event handler for the specified event type.
This is used to listen for watch events.
watch.on(WatchEventType.Changed, (event: WatchEvent, emitter: WatchEventEmitter): void {
// Do something with the event!
})
The event type to add the event for.
The callback handler.
The emitter instance.
Update the grid with the new events information.
Static
closeClose all watches for the given subject.
Please note, this method doesn't normally need to be called
and is designed to be used internally. If you want
to close a watch then please just call Watch.#close()
instead.
The subject to close watches for.
Static
inspectStatic
openStatic
updateUpdate the grid with the new events.
A cache of ids to dict indexes in the grid.
The grid to update.
The events to update the grid with.
A haystack Watch.