Tide · API
createTide
createTide builds a Tide from options the host supplies: a store for its rows, a transform that evaluates templates, a select that executes a reflex’s query, and effects, the effect handlers by name. Tide calls these and nothing else. In the example, select and the effect handler record the input each receives.
const tide = createTide({
store: createMemoryStore(),
transform: evaluate, // Prism
select: (query) => passes.filter((pass) => pass.amount_cents > query.over),
effects: { 'payments.charge': { run: (input) => gateway.charge(input) } },
});{
id: 'billing.charge',
intent: 'On the first of the month, charge every season pass above a hundred euros.',
on: {
clock: {
every: 'month',
on: 1,
at: '03:00',
tz: 'Europe/Vienna',
},
},
params: { over: 10000 },
select: {
query: { table: 'passes', over: { $ref: '$.params.over' } },
mode: 'each',
unitKey: 'member',
},
effect: {
name: 'payments.charge',
input: {
member: { $ref: '$.row.member' },
amount: { $ref: '$.row.amount_cents' },
},
},
}{
select: [{ table: 'passes', over: 10000 }],
effect: [{ member: 'grace', amount: 12000 }],
}Runs in this page on the installed package. The input and the expected output are defined by the example.