MetaFor - v0.3.1
    Preparing search index...

    Type Alias ReactionFilterArgs

    Аргументы для функции фильтрации

    Содержит метаданные сообщения и патч для проверки условий фильтра.

    import { ReactionRegistry, createReactionsChain } from "../index"
    import type { Update, ExtractValues } from "../../context/index.t"
    import { test, expect } from "bun:test"
    import type { JsonPatch, MetaDataMessage } from "../../message"

    type Ctx = {
    value: { type: "number"; required: true }
    name: { type: "string"; required: true }
    isActive: { type: "boolean"; required: true }
    tags: { type: "array"; required: true }
    }
    type State = "idle" | "active" | "error"

    test("Создание уникальных реакций", () => {
    const registry = new ReactionRegistry<Ctx, State>((reaction) => [
    [
    ["idle", "active"],
    reaction({ title: "inc" })
    .filter({
    tag: "test",
    op: "replace",
    path: "/context",
    value: 1,
    })
    .equal(({ update, context }) => update({ value: context.value + 1 })),
    ],
    [
    ["error"],
    reaction({ title: "reset" })
    .filter({ tag: "any" })
    .equal(({ update }) => update({ value: 0 })),
    ],
    ])

    const all = registry.getAllReactions()
    expect(all?.length, "уникальные реакции").toBe(2)
    expect(all?.[0]?.title, "первая реакция").toBe("inc")
    expect(all?.[1]?.title, "вторая реакция").toBe("reset")
    })
    type ReactionFilterArgs = {
        meta: MetaDataMessage;
        patch: JsonPatch;
    }
    Index

    Properties

    Properties

    Метаданные сообщения (тег, индекс, временная метка)

    patch: JsonPatch

    JSON Patch с операцией, путем и значением