Inbox
Delivers one native library's results to the app.
The library has a single queue. It adds an entry for each watched future, stream or value that has something new: a settled future, a stream with an item, a changed value. This class drains that queue and calls the watchers registered for each entry. All results from a library are therefore delivered through one path, in order, and one wait covers all of them.
A binding creates one for its library from two functions: wait takes a timeout in milliseconds (negative for no timeout) and returns whether anything is queued, and next returns the id of the next queued entry, or -1.
Future.then, Stream.listen and Reactive.follow are built on watch. An app with its own reactive graph can call follow here directly.
Constructor
function new(wait:(Int) -> Bool, next:() -> Int)Methods
function watch(id:Int, deliver:() -> Bool):() -> VoidRegisters deliver to be called during sync whenever the library queues id, and once initially. deliver returns whether it should keep being called. Returns a function that unregisters it.
function follow(id:Int, seen:Int, wait:(seen:Int, limit:Int) -> Int, read:() -> T, sink:(T) -> Void):() -> VoidCalls sink with a value the library keeps up to date, each time it has changed since seen, the version at which the caller read it. wait and read are the library's functions for that value, as described in Reactive.follow. Returns a function that stops it.
function sync():BoolDelivers this library's ready results on the calling thread. Returns whether anything is still being watched. Loop.sync calls this for every library.