• Public
  • Public/Protected
  • All

A m-ld clone represents domain data to an app.

The Javascript clone engine uses a database engine, for which in-memory, on-disk and in-browser persistence options are available (see Getting Started).








Readonly status

status: Observable<MeldStatus> & LiveStatus

The current and future status of a clone. This stream is hot and continuous, terminating when the clone closes (and can therefore be used to detect closure).



  • close(err?: any): Promise<unknown>
  • Closes this clone engine gracefully. Using this method ensures that data has been fully flushed to storage and all transactions have been notified to the domain (if this clone is online).


    • Optional err: any

      used to notify a reason for the closure, for example an application failure, for problem diagnosis.

    Returns Promise<unknown>


  • Shorthand method for deleting a single Subject by its @id. This will also remove references to the given Subject from other Subjects.


    • id: string

      the Subject @id

    Returns Promise<MeldState>


  • Handle updates from the domain, from the moment this method is called. All data changes are signalled through the handler, strictly ordered according to the clone's logical clock. The updates can therefore be correctly used to maintain some other view of data, for example in a user interface or separate database. This will include the notification of 'rev-up' updates after a connect to the domain. To change this behaviour, ignore updates while the clone status is marked as outdated.

    This method is equivalent to calling read with a no-op procedure.


    • handler: UpdateProc

      a procedure to run for every update

    Returns Subscription

    a subscription, allowing the caller to unsubscribe the handler


  • get<S>(id: string): Promise<Resource<S> | undefined>
  • Shorthand method for retrieving a single Subject by its @id, if it exists.

    Type parameters

    • S


    • id: string

      the Subject @id

    Returns Promise<Resource<S> | undefined>

    a promise resolving to the requested Subject, or undefined if not found


  • Performs some read procedure on the current state, with notifications of subsequent updates.

    The state passed to the procedure is immutable and is guaranteed to remain 'live' until the procedure's return Promise resolves or rejects.


    • procedure: StateProc

      a procedure to run for the current state

    • Optional handler: UpdateProc

      a procedure to run for every update that follows the state in the procedure

    Returns Subscription

  • Actively reads data from the domain.

    The query executes in response to either subscription to the returned result, or calling .then.

    All results are guaranteed to derive from the current state; however since the observable results are delivered asynchronously, the current state is not guaranteed to be live in the subscriber. In order to keep this state alive during iteration (for example, to perform a consequential operation), perform the request in the scope of a read procedure instead.

    Type parameters


    • request: R

      the declarative read description

    Returns ReadResult<Resource<S>>

    read subjects


  • Performs some write procedure on the current state.

    The state passed to the procedure is immutable and is guaranteed to remain 'live' until its write method is called, or the procedure's return Promise resolves or rejects.


    • procedure: StateProc<MeldState>

      a procedure to run against the current state. This procedure is able to modify the given state incrementally using its write method

    Returns Promise<MeldState>

  • Actively writes data to the domain.

    Type parameters

    • W

      one of the Write types


    • request: W

      the declarative write description

    Returns Promise<MeldState>

    the next state of the domain, changed by this write operation only


  • Property
  • Method

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