0.2.5 #43

Merged
Thilawyn merged 94 commits from next into master 2026-03-31 21:01:13 +02:00
Showing only changes of commit 45bf604381 - Show all commits

View File

@@ -96,4 +96,44 @@ describe("Lens", () => {
expect(Chunk.toReadonlyArray(updated)).toEqual([1, 2, 99]) expect(Chunk.toReadonlyArray(updated)).toEqual([1, 2, 99])
}) })
// test("changes stream emits updates when lens mutates state", async () => {
// const events = await Effect.runPromise(
// Effect.flatMap(
// SubscriptionRef.make({ count: 0 }),
// parent => {
// const lens = Lens.mapField(Lens.fromSubscriptionRef(parent), "count")
// return Effect.fork(Stream.runCollect(Stream.take(lens.changes, 2))).pipe(
// Effect.tap(Lens.set(lens, 1)),
// Effect.tap(Lens.set(lens, 1)),
// Effect.andThen(Fiber.join),
// Effect.map(Chunk.toReadonlyArray),
// )
// },
// ),
// )
// expect(events).toEqual([1, 2])
// })
// test("mapped changes stream can derive transformed values", async () => {
// const derived = await Effect.runPromise(
// Effect.flatMap(
// SubscriptionRef.make({ count: 10 }),
// parent => {
// const lens = Lens.mapField(Lens.fromSubscriptionRef(parent), "count")
// const transformed = Stream.map(lens.changes, count => `count:${ count }`)
// return Effect.scoped(() => Effect.flatMap(
// Effect.forkScoped(Stream.runCollect(Stream.take(transformed, 1))),
// fiber => Effect.flatMap(
// Lens.set(lens, 42),
// () => Effect.join(fiber),
// ),
// ))
// },
// ),
// )
// expect(derived).toEqual(["count:42"])
// })
}) })