Skip to content

Commit

Permalink
Upgrade to Effection 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
cowboyd committed Jan 30, 2024
1 parent 7130ede commit 91b23ed
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion javascript-effection/deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
}
},
"imports": {
"effection": "https://deno.land/x/[email protected].0-alpha.13/mod.ts",
"effection": "https://deno.land/x/[email protected].2/mod.ts",
"expect": "https://deno.land/x/[email protected]/mod.ts",
"node:test": "https://deno.land/[email protected]/testing/bdd.ts"
}
Expand Down
18 changes: 14 additions & 4 deletions javascript-effection/easyracer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import {
action,
call,
createContext,
expect as $await,
type Operation,
sleep,
spawn,
Expand Down Expand Up @@ -43,16 +42,27 @@ export function timeout<T>(
*/
export const request = (query?: string) =>
call(function* () {
let signal = yield* useAbortSignal();
let controller = new AbortController();
let { signal } = controller;
let url = `${yield* BaseURL}/${yield* Scenario}${query ? "?" + query : ""}`;

let promises: Promise<unknown>[] = [];

let request = fetch(url, { signal });

promises.push(request);

try {
let response = yield* $await(request);
return yield* $await(response.text());
let response = yield* call(() => request);
let text = response.text();
promises.push(text);

return yield* call(() => text);
} catch (error) {
return String(error);
} finally {
controller.abort();
yield* call(() => Promise.allSettled(promises));
}
});

Expand Down
2 changes: 1 addition & 1 deletion javascript-effection/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"private": true,
"type": "module",
"dependencies": {
"effection": "3.0.0-alpha.13",
"effection": "3.0.2",
"expect": "*"
},
"scripts": {
Expand Down

0 comments on commit 91b23ed

Please sign in to comment.