@@ -105,14 +105,26 @@ export const makeFromPath = <
|
|||||||
(parentValue, value) => Option.getOrThrow(PropertyPath.immutableSet(parentValue, path, value)),
|
(parentValue, value) => Option.getOrThrow(PropertyPath.immutableSet(parentValue, path, value)),
|
||||||
)
|
)
|
||||||
|
|
||||||
export const makeFromChunkRef = <A, B extends SubscriptionRef.SubscriptionRef<Chunk.Chunk<any> | Chunk.NonEmptyChunk<any>>>(
|
export const makeFromChunkRef: {
|
||||||
parent: B,
|
<B extends SubscriptionRef.SubscriptionRef<Chunk.NonEmptyChunk<any>>>(
|
||||||
|
parent: B,
|
||||||
|
index: number,
|
||||||
|
): SubscriptionSubRef<
|
||||||
|
Effect.Effect.Success<B> extends Chunk.NonEmptyChunk<infer A> ? A : never,
|
||||||
|
B
|
||||||
|
>
|
||||||
|
<B extends SubscriptionRef.SubscriptionRef<Chunk.Chunk<any>>>(
|
||||||
|
parent: B,
|
||||||
|
index: number,
|
||||||
|
): SubscriptionSubRef<
|
||||||
|
Effect.Effect.Success<B> extends Chunk.Chunk<infer A> ? A : never,
|
||||||
|
B
|
||||||
|
>
|
||||||
|
} = (
|
||||||
|
parent: SubscriptionRef.SubscriptionRef<Chunk.Chunk<any>>,
|
||||||
index: number,
|
index: number,
|
||||||
): SubscriptionSubRef<
|
) => new SubscriptionSubRefImpl(
|
||||||
Effect.Effect.Success<B> extends Chunk.Chunk<infer A> ? A : never,
|
parent,
|
||||||
B
|
|
||||||
> => new SubscriptionSubRefImpl(
|
|
||||||
parent as SubscriptionRef.SubscriptionRef<Chunk.Chunk<any>>,
|
|
||||||
parentValue => Chunk.unsafeGet(parentValue, index),
|
parentValue => Chunk.unsafeGet(parentValue, index),
|
||||||
(parentValue, value) => Chunk.replace(parentValue, index, value),
|
(parentValue, value) => Chunk.replace(parentValue, index, value),
|
||||||
) as any
|
) as any
|
||||||
|
|||||||
@@ -10,8 +10,8 @@ import * as React from "react"
|
|||||||
|
|
||||||
const RouteComponent = Component.make(function* RouteComponent() {
|
const RouteComponent = Component.make(function* RouteComponent() {
|
||||||
const [value, setValue] = React.useState("")
|
const [value, setValue] = React.useState("")
|
||||||
const myRef = yield* SubscriptionRef.make(Chunk.make({ name: "person 1" } as const))
|
// const myRef = yield* SubscriptionRef.make(Chunk.make({ name: "person 1" } as const))
|
||||||
// const myRef = yield* SubscriptionRef.make(Chunk.empty<{ readonly name: "person 1" }>())
|
const myRef = yield* SubscriptionRef.make(Chunk.empty<{ readonly name: "person 1" }>())
|
||||||
const mySubRef = SubscriptionSubRef.makeFromChunkRef(myRef, 0)
|
const mySubRef = SubscriptionSubRef.makeFromChunkRef(myRef, 0)
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
|||||||
Reference in New Issue
Block a user