Sync / foldkit-sync

DeclaredTransition

interface · packages/sync/src/make.ts:125

interface DeclaredTransition<Shared, Message> {
  readonly bind: <AppModel, All>(document: {
    readonly tag: string
    readonly shared: Schema.Codec<Shared, unknown>
    readonly projection: {
      readonly get: (model: AppModel) => Shared
      readonly set: (model: AppModel, shared: Shared) => AppModel
    }
    readonly constructors: ReadonlyArray<unknown>
    readonly laws: ReadonlyArray<Pick<Law<Shared, string>, 'holds'>>
    readonly next: DeclaredReplay<Shared, AppModel, All>
  }) => DeclaredReplay<Shared, AppModel, All>
  readonly _message?: (message: Message) => void
}

A durable Message's replay declared apart from the application's update, as foldkit-sync/metakit's SyncDeclared.transition builds it. make calls bind once with the document: it throws where tag is not one of constructors or the declaration is unsound under laws, and gives the document's DeclaredReplay with this tag's in it, next answering for every other tag. Message is only the Message the declaration was written for.

Members

DeclaredTransition.bind

property · packages/sync/src/make.ts:126

readonly bind: <AppModel, All>(document: {
  readonly tag: string
  readonly shared: Schema.Codec<Shared, unknown>
  readonly projection: {
    readonly get: (model: AppModel) => Shared
    readonly set: (model: AppModel, shared: Shared) => AppModel
  }
  readonly constructors: ReadonlyArray<unknown>
  readonly laws: ReadonlyArray<Pick<Law<Shared, string>, 'holds'>>
  readonly next: DeclaredReplay<Shared, AppModel, All>
}) => DeclaredReplay<Shared, AppModel, All>

DeclaredTransition._message

property · packages/sync/src/make.ts:140

readonly _message?: (message: Message) => void

Not read: it keeps a declaration for one Message from standing under another's tag.