Sync / foldkit-sync/journal

reaction

function · packages/sync/src/serverJournal.ts:167

function reaction<
  AppModel,
  Fields extends Schema.Struct.Fields,
  Message,
  Ms extends readonly unknown[],
  ContractPrincipal,
  Authorized extends boolean,
  SMs extends readonly unknown[],
  On extends MsgOf<Ms> | ServerMsgOf<SMs>,
  Appends extends ServerMsgOf<SMs> = never,
  R = never,
>(
  sync: DefinedSync<
    AppModel,
    Fields,
    Message,
    Ms,
    ContractPrincipal,
    Authorized,
    SMs
  >,
  options: ReactionOptions<AppModel, On, Appends, R>,
): Reaction<
  DefinedSync<
    AppModel,
    Fields,
    Message,
    Ms,
    ContractPrincipal,
    Authorized,
    SMs
  >,
  R
>

Declares a reaction of a contract from Sync.forApplication(App).make: after each committed Message in on, in journal order, run is called once at least, and what it answers is appended as the server. A handler that keeps failing is parked after attempts failures over parkAfter; one whose answer can never commit is parked at once. Throws for a name that is not one, or a set of another application or outside the contract.