A promise that is resolved when all results have been consumed by
subscribers (either to this
, or to this.consume
).
Allows the subscriber to exert back-pressure
Allows handling of each read subject in turn. If the handler returns a Promise, the next subject will not be handled until the promise has resolved. If the handler throws or returns a rejected promise, no more subjects will be handled and the return will be a rejected promise.
a handler for each subject
Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.8.2 Source code licensed MIT. Privacy policy
Convenience return type for reading data from a clone. Use as a Promise with
.then
orawait
to obtain the results as an array of identified Subjects (with a graph mode). Use as an Observable with.subscribe
(or other RxJS methods) to be notified of individual Subjects as they arrive. Or consume the results one-by-one with back-pressure usingFlowable.consume
.Read results (even if consumed outside the scope of a read procedure) will not be affected by concurrent writes (this is equivalent to serialisability). Therefore, results can be safely used to strictly maintain a downstream data model. Care must still be taken to ensure that results do not interleave with the results of a prior read, if the downstream consumer is slow.
const query = { '@describe': '?id', '@where': { '@graph': { '@id': '?id', age: '?age' }, '@filter': { '@lt': ['?age', 50] } } }; // Process the results as a single array meld.read(query).then(subjects => subjects.forEach(displayUi)); // Traverse a graph of results meld.read(query).then(subjects => console.log(subjects.graph['fred']?.wife?.name)); // Process the results one-by-one as fast as they arrive meld.read(query).subscribe(subject => displayUi(subject)); // Process the results only as fast as expensive processing can go meld.read(query).consume.subscribe(({ value: subject, next }) => expensiveAsyncProcess(subject).finally(next));
MeldStateMachine.read