Options
All
  • Public
  • Public/Protected
  • All
Menu

Extensions applied to a m-ld clone.

Extensions can then be installed in two ways:

  1. By providing the implementation in the app parameter of the clone function.
  2. By declaring a module in the domain information.

The first option is suitable when the data is always going to be used by the same app – because the app will always know it has to include the extension.

The second option is more suitable if the data may be shared to other apps, because the need for the extension is declared in the data itself, and apps can load it dynamically as required.

To write an extension to be declared in the domain data, implement MeldExtensions with one or more of its methods, in a Javascript class. Then, to declare the extension in the domain, you write:

{
  "@id": "http://m-ld.org/extensions",
  "@list": {
    "≪priority≫": {
      "@id": "≪your-extension-iri≫",
      "@type": "http://js.m-ld.org/#CommonJSExport",
      "http://js.m-ld.org/#require": "≪your-extension-module≫",
      "http://js.m-ld.org/#class": "≪your-extension-class-name≫"
    }
  }
}

Breaking this down:

  • "http://m-ld.org/extensions" is the identity of the extensions list. This is a constant that m-ld knows about (it's in the m-ld.org domain).
  • The extensions list is declared as a List, with the @list keyword, because extensions are ordered by priority.
  • The value you give for ≪priority≫ (a number) will determine where in the list your extension appears. The highest priority is "0". The value is decided by you, based on what you know about your extensions. In most cases it won't matter, since extensions shouldn't interfere with each other.
  • The "@type" identifies this extension as a Javascript module loaded in CommonJS style. (We'll support ES6 modules in future.)
  • The "http://js.m-ld.org/#require" and "http://js.m-ld.org/#class" properties tell the module loader how to instantiate your module class. It will call a global require function with the first, dereference the second and call new on it.

Most extensions will provide a static convenience function to generate this JSON, which can be called in the genesis clone (example).

experimental

Hierarchy

  • MeldExtensions

Implemented by

Index

Properties

Optional Readonly agreementConditions

agreementConditions: Iterable<AgreementCondition>

Agreement preconditions applicable to the domain.

experimental

Optional Readonly constraints

constraints: Iterable<MeldConstraint>

Data invariant constraints applicable to the domain.

experimental

Optional Readonly transportSecurity

transportSecurity: MeldTransportSecurity

A transport security interceptor. If the initial transport security is not compatible with the rest of the domain, this clone may not be able to join until the app is updated.

experimental

Legend

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

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