0.1.3 #4
@@ -105,14 +105,26 @@ export const makeFromPath = <
|
||||
(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: {
|
||||
<B extends SubscriptionRef.SubscriptionRef<Chunk.NonEmptyChunk<any>>>(
|
||||
parent: B,
|
||||
index: number,
|
||||
): SubscriptionSubRef<
|
||||
): 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
|
||||
> => new SubscriptionSubRefImpl(
|
||||
parent as SubscriptionRef.SubscriptionRef<Chunk.Chunk<any>>,
|
||||
>
|
||||
} = (
|
||||
parent: SubscriptionRef.SubscriptionRef<Chunk.Chunk<any>>,
|
||||
index: number,
|
||||
) => new SubscriptionSubRefImpl(
|
||||
parent,
|
||||
parentValue => Chunk.unsafeGet(parentValue, index),
|
||||
(parentValue, value) => Chunk.replace(parentValue, index, value),
|
||||
) as any
|
||||
|
||||
@@ -10,8 +10,8 @@ import * as React from "react"
|
||||
|
||||
const RouteComponent = Component.make(function* RouteComponent() {
|
||||
const [value, setValue] = React.useState("")
|
||||
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.make({ name: "person 1" } as const))
|
||||
const myRef = yield* SubscriptionRef.make(Chunk.empty<{ readonly name: "person 1" }>())
|
||||
const mySubRef = SubscriptionSubRef.makeFromChunkRef(myRef, 0)
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user