@effectionx/effect-ts 0.1.0 → 0.1.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/effect.test.ts +12 -8
  2. package/package.json +6 -2
package/effect.test.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { describe, it } from "@effectionx/bdd";
2
2
  import { Context, Effect, Exit, Fiber, Layer } from "effect";
3
- import { call, scoped, sleep, spawn, suspend } from "effection";
3
+ import { call, scoped, sleep, spawn, suspend, withResolvers } from "effection";
4
4
  import { expect } from "expect";
5
5
 
6
6
  import {
@@ -157,7 +157,8 @@ describe("@effectionx/effect-ts", () => {
157
157
  describe("cancellation", () => {
158
158
  it("interrupts Effect when Effection task is halted", function* () {
159
159
  let finalizerRan = false;
160
- let effectStarted = false;
160
+ const { resolve: effectReady, operation: waitForEffectReady } =
161
+ withResolvers<void>();
161
162
 
162
163
  // Run in a nested scope so we can control when it ends
163
164
  yield* scoped(function* () {
@@ -167,23 +168,23 @@ describe("@effectionx/effect-ts", () => {
167
168
  yield* spawn(function* () {
168
169
  yield* runtime.run(
169
170
  Effect.gen(function* () {
170
- effectStarted = true;
171
171
  yield* Effect.addFinalizer(() =>
172
172
  Effect.sync(() => {
173
173
  finalizerRan = true;
174
174
  }),
175
175
  );
176
+ // Signal after finalizer is registered
177
+ effectReady();
176
178
  yield* Effect.sleep("10 seconds");
177
179
  }).pipe(Effect.scoped),
178
180
  );
179
181
  });
180
182
 
181
- // Give the effect time to start before scope ends
182
- yield* sleep(50);
183
+ // Wait for the effect to register finalizer before scope ends
184
+ yield* waitForEffectReady;
183
185
  });
184
186
 
185
187
  // After the scoped block completes, the finalizer should have run
186
- expect(effectStarted).toEqual(true);
187
188
  expect(finalizerRan).toEqual(true);
188
189
  });
189
190
  });
@@ -417,6 +418,8 @@ describe("@effectionx/effect-ts", () => {
417
418
  describe("resource cleanup", () => {
418
419
  it("cleans up Effect resources when Effection scope halts", function* () {
419
420
  const cleanupOrder: string[] = [];
421
+ const { resolve: resourceAcquired, operation: waitForAcquire } =
422
+ withResolvers<void>();
420
423
 
421
424
  yield* scoped(function* () {
422
425
  const runtime = yield* makeEffectRuntime();
@@ -427,6 +430,7 @@ describe("@effectionx/effect-ts", () => {
427
430
  yield* Effect.acquireRelease(
428
431
  Effect.sync(() => {
429
432
  cleanupOrder.push("acquired");
433
+ resourceAcquired();
430
434
  }),
431
435
  () =>
432
436
  Effect.sync(() => {
@@ -439,8 +443,8 @@ describe("@effectionx/effect-ts", () => {
439
443
  );
440
444
  });
441
445
 
442
- yield* sleep(50);
443
- // Scope ends here, halting the spawned task
446
+ // Wait for the resource to be acquired before scope ends
447
+ yield* waitForAcquire;
444
448
  });
445
449
 
446
450
  // After scoped block completes, cleanup should have happened
package/package.json CHANGED
@@ -1,12 +1,15 @@
1
1
  {
2
2
  "name": "@effectionx/effect-ts",
3
- "version": "0.1.0",
3
+ "description": "Bidirectional interop between Effect-TS and Effection",
4
+ "version": "0.1.2",
4
5
  "type": "module",
5
6
  "main": "./dist/mod.js",
6
7
  "types": "./dist/mod.d.ts",
7
8
  "exports": {
8
9
  ".": {
10
+ "types": "./dist/mod.d.ts",
9
11
  "development": "./mod.ts",
12
+ "import": "./dist/mod.js",
10
13
  "default": "./dist/mod.js"
11
14
  }
12
15
  },
@@ -16,7 +19,8 @@
16
19
  },
17
20
  "devDependencies": {
18
21
  "effect": "^3",
19
- "@effectionx/bdd": "0.4.1"
22
+ "effection": "^4",
23
+ "@effectionx/bdd": "0.4.3"
20
24
  },
21
25
  "license": "MIT",
22
26
  "author": "engineering@frontside.com",