repos / starfx

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

commit
2a61af0
parent
56f96ae
author
Eric Bower
date
2024-08-16 18:50:26 +0000 UTC
fix(thunk): run thunk supervisors immediately on register

For whatever reason, dispatching actions to register all the supervisor
thunks was too slow and causing a regression with prod systems.

This reverts part of the register function to how it used to work.  To
be more specific, it calls the supervisor functions immediately in a
`parallel` call.
1 files changed,  +3, -3
M query/thunk.ts
+3, -3
 1@@ -1,6 +1,6 @@
 2 import { compose } from "../compose.ts";
 3 import type { ActionWithPayload, AnyAction, Next, Payload } from "../types.ts";
 4-import { ActionContext, createAction, put, takeEvery } from "../action.ts";
 5+import { ActionContext, createAction, takeEvery } from "../action.ts";
 6 import { isFn, isObject } from "./util.ts";
 7 import { createKey } from "./create-key.ts";
 8 import type {
 9@@ -14,7 +14,7 @@ import type {
10 } from "./types.ts";
11 import { API_ACTION_PREFIX } from "../action.ts";
12 import { Callable, Ok, Operation, Signal, spawn } from "../deps.ts";
13-import { supervise } from "../fx/mod.ts";
14+import { keepAlive, supervise } from "../fx/mod.ts";
15 
16 const registerThunk = createAction<Callable<unknown>>(
17   `${API_ACTION_PREFIX}REGISTER_THUNK`,
18@@ -258,7 +258,7 @@ export function createThunks<Ctx extends ThunkCtx = ThunkCtx<any>>(
19     });
20 
21     // register any thunks already created
22-    yield* put(Object.values(visors).map(registerThunk));
23+    yield* keepAlive(Object.values(visors));
24 
25     yield* task;
26   }