From 88a4b9286d1eb9c9a55e1cbdec87fb72463b9e60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Fri, 22 May 2026 01:23:33 +0200 Subject: [PATCH] Refactor --- packages/effect-lens/src/Lens.ts | 22 +++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/packages/effect-lens/src/Lens.ts b/packages/effect-lens/src/Lens.ts index e9bf203..82eabc0 100644 --- a/packages/effect-lens/src/Lens.ts +++ b/packages/effect-lens/src/Lens.ts @@ -34,6 +34,7 @@ export type LensStepTypeId = typeof LensTypeId export interface LensStep { readonly [LensStepTypeId]: LensStepTypeId readonly transform: (parent: B) => Effect.Effect + readonly transformStream: (parent: B) => Stream.Stream readonly update: (next: A, parent: B) => Effect.Effect } @@ -52,18 +53,29 @@ export const isLensStep = (u: unknown): u is LensStep +export abstract class LensImpl< + in out A, + in out B, + in out ER = never, + in out EW = never, + in out RR = never, + in out RW = never, + in out SourceER = never, + in out SourceEW = never, + in out SourceRR = never, + in out SourceRW = never, +> extends Pipeable.Class() implements Lens { readonly [Readable.TypeId]: Readable.TypeId = Readable.TypeId readonly [Subscribable.TypeId]: Subscribable.TypeId = Subscribable.TypeId readonly [LensTypeId]: LensTypeId = LensTypeId readonly [LensImplTypeId]: LensImplTypeId = LensImplTypeId - readonly steps: readonly LensStep[] = [] + readonly steps: readonly LensStep[] = [] - abstract readonly sourceGet: Effect.Effect - abstract readonly sourceChanges: Stream.Stream - abstract readonly sourceCommit: (a: A) => Effect.Effect + abstract readonly sourceGet: Effect.Effect + abstract readonly sourceChanges: Stream.Stream + abstract readonly sourceCommit: (b: B) => Effect.Effect abstract readonly withLock: (self: Effect.Effect) => Effect.Effect get get(): Effect.Effect {