Options
All
  • Public
  • Public/Protected
  • All
Menu

Convenience return type for reading data from a clone. Use as a Promise with .then or await 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 using Flowable.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));
see

MeldStateMachine.read

Hierarchy

Implements

Index

Properties

Properties

Readonly completed

completed: PromiseLike<unknown>

A promise that is resolved when all results have been consumed by subscribers (either to this, or to this.consume).

Readonly consume

consume: Consumable<GraphSubject>

Allows the subscriber to exert back-pressure

see

https://www.npmjs.com/package/rx-flowable

Legend

  • Property
  • Method
  • Constructor

Generated using TypeDoc. Delivered by Vercel. @m-ld/m-ld - v0.8.2 Source code licensed MIT. Privacy policy