diff --git a/packages/effect-lens/src/Lens.ts b/packages/effect-lens/src/Lens.ts index f6a213b..9959aa1 100644 --- a/packages/effect-lens/src/Lens.ts +++ b/packages/effect-lens/src/Lens.ts @@ -193,17 +193,18 @@ extends LensImpl { get resolve(): Effect.Effect, never, never> { return Effect.map( - this.ref.get, + Ref.get(this.ref.ref), value => ({ value, - commit: next => Effect.flatMap(next, value => this.commit(value)), + commit: next => Effect.flatMap( + next, + value => Ref.set(this.ref.ref, value), + ), }), ) } - get changes() { return Stream.unwrap(Effect.map(this.ref.get, Stream.make)) } + get changes() { return Stream.unwrap(Effect.map(Ref.get(this.ref.ref), Stream.make)) } get withLock() { return this.ref.withLock } - - commit(a: A) { return Ref.set(this.ref.ref, a) } } /** @@ -239,19 +240,18 @@ extends LensImpl { this.ref.get, value => ({ value, - commit: next => Effect.flatMap(next, value => this.commit(value)), + commit: next => Effect.flatMap( + next, + value => Effect.zipLeft( + Ref.set(this.ref.ref, value), + PubSub.publish(this.ref.pubsub, value), + ), + ), }), ) } get changes() { return this.ref.changes } get withLock() { return this.ref.semaphore.withPermits(1) } - - commit(a: A) { - return Effect.zipLeft( - Ref.set(this.ref.ref, a), - PubSub.publish(this.ref.pubsub, a), - ) - } } /**