This commit is contained in:
@@ -96,4 +96,44 @@ describe("Lens", () => {
|
||||
|
||||
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"])
|
||||
// })
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user