This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { Array, Chunk, Effect, Function, Pipeable, Predicate, Readable, Stream, Subscribable, SubscriptionRef } from "effect"
|
||||
import { Array, Chunk, Effect, Function, Pipeable, Predicate, Readable, Stream, Subscribable, type SubscriptionRef } from "effect"
|
||||
import type { NoSuchElementException } from "effect/Cause"
|
||||
|
||||
|
||||
@@ -139,7 +139,7 @@ export const mapEffect: {
|
||||
)),
|
||||
}))
|
||||
|
||||
export const mapStructField: {
|
||||
export const mapField: {
|
||||
<A extends object, K extends keyof A, ER, EW, RR, RW>(
|
||||
self: Lens<A, ER, EW, RR, RW>,
|
||||
key: K,
|
||||
@@ -287,24 +287,3 @@ export const updateAndGetEffect: {
|
||||
next => Effect.succeed([next, next] as const),
|
||||
)),
|
||||
)
|
||||
|
||||
|
||||
Effect.gen(function*() {
|
||||
const ref = yield* SubscriptionRef.make({
|
||||
values: [13, 69, 1488] as readonly number[]
|
||||
} as const)
|
||||
|
||||
const myValueLens = ref.pipe(
|
||||
fromSubscriptionRef,
|
||||
mapStructField("values"),
|
||||
mapArrayAt(1),
|
||||
)
|
||||
|
||||
const myValueLens2 = mapArrayAt(mapStructField(fromSubscriptionRef(ref), "values"), 1)
|
||||
|
||||
console.log(yield* ref.get, yield* myValueLens.get)
|
||||
yield* set(myValueLens, 22)
|
||||
console.log(yield* ref.get, yield* myValueLens.get)
|
||||
}).pipe(
|
||||
Effect.runSync
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user