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

Methods

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

Methods

each

  • each(handle: (value: GraphSubject) => any): Promise<unknown>
  • 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.

    Parameters

    Returns Promise<unknown>

Legend

  • Constructor
  • Property
  • Method
  • Property
  • Method
  • Inherited property
  • Inherited method
  • Static property
  • Static method
  • Protected method

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