repos / starfx

supercharged async flow control library.
git clone https://github.com/neurosnap/starfx.git

commit
da3a409
parent
7970673
author
Eric Bower
date
2023-12-01 18:38:43 +0000 UTC
fix(thunk): add `.use` to `CreateActionWithPayload` (#27)

2 files changed,  +6, -3
M query/thunk.ts
+4, -2
 1@@ -17,7 +17,7 @@ import type {
 2   ThunkCtx,
 3 } from "./types.ts";
 4 import { API_ACTION_PREFIX } from "../action.ts";
 5-import { Callable, Ok } from "../deps.ts";
 6+import { Callable, Ok, Operation } from "../deps.ts";
 7 
 8 export interface ThunksApi<Ctx extends ThunkCtx> {
 9   use: (fn: Middleware<Ctx>) => void;
10@@ -140,7 +140,9 @@ export function createThunks<Ctx extends ThunkCtx = ThunkCtx<any>>(
11   const createType = (post: string) =>
12     `${API_ACTION_PREFIX}${post.startsWith("/") ? "" : "/"}${post}`;
13 
14-  function* onApi<P extends CreateActionPayload>(action: ActionWithPayload<P>) {
15+  function* onApi<P extends CreateActionPayload>(
16+    action: ActionWithPayload<P>,
17+  ): Operation<Ctx> {
18     const { name, key, options } = action.payload;
19     const actionFn = actionMap[name];
20     const ctx = {
M query/types.ts
+2, -1
 1@@ -119,9 +119,10 @@ export type CreateActionFnWithPayload<P = any> = (
 2   p: P,
 3 ) => ActionWithPayload<CreateActionPayload<P>>;
 4 
 5-export interface CreateActionWithPayload<Ctx, P>
 6+export interface CreateActionWithPayload<Ctx extends ThunkCtx, P>
 7   extends CreateActionFnWithPayload<P> {
 8   run: (a: ActionWithPayload<CreateActionPayload<P>>) => Operation<Ctx>;
 9+  use: (mdw: Middleware<Ctx>) => void;
10 }
11 
12 export type Supervisor<T = unknown> = (