execute workflows asynchronously

This commit is contained in:
yoan
2025-01-09 20:00:15 +08:00
parent 6badc0f419
commit ebffac7ba4
6 changed files with 162 additions and 21 deletions

View File

@@ -1,3 +1,4 @@
import type { RecordModel, RecordSubscription } from "pocketbase";
import { ClientResponseError } from "pocketbase";
import { WORKFLOW_TRIGGERS } from "@/domain/workflow";
@@ -23,3 +24,15 @@ export const run = async (id: string) => {
return resp;
};
export const subscribe = async (id: string, cb: (e: RecordSubscription<RecordModel>) => void) => {
const pb = getPocketBase();
pb.collection("workflow").subscribe(id, cb);
};
export const unsubscribe = async (id: string) => {
const pb = getPocketBase();
pb.collection("workflow").unsubscribe(id);
};