applyChecklistAction
applyChecklistAction(
items,action,newId?):ChecklistItem[] |undefined
The items after action, or undefined when it isn’t one of the checklist’s own
(CHECKLIST) or names an item that isn’t there: then it’s one of your buttons.
async onAction(ctx, action) { const items = (await ctx.storage.get<ChecklistItem[]>("items")) ?? []; const next = applyChecklistAction(items, action); if (!next) return; await ctx.storage.set("items", next); ctx.emit(checklist({ key: "todo", title: "To do", items: next, addable: true, editable: true }));}newId names an added item; by default a random UUID.
Parameters
Section titled “Parameters”| Parameter | Type | Default value |
|---|---|---|
items |
readonly ChecklistItem[] |
undefined |
action |
Pick<ActionEvent, "actionId" | "itemId" | "input"> |
undefined |
newId |
() => string |
randomId |
Returns
Section titled “Returns”ChecklistItem[] | undefined