From c8b675d93e73b902421fab4a8f67e6fa573c2676 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Valverd=C3=A9?= Date: Mon, 5 May 2025 03:33:50 +0200 Subject: [PATCH] Fix --- packages/reffuse/src/ReffuseNamespace.ts | 37 +++++++++++++++++------- 1 file changed, 26 insertions(+), 11 deletions(-) diff --git a/packages/reffuse/src/ReffuseNamespace.ts b/packages/reffuse/src/ReffuseNamespace.ts index 66b3400..d768eb5 100644 --- a/packages/reffuse/src/ReffuseNamespace.ts +++ b/packages/reffuse/src/ReffuseNamespace.ts @@ -30,7 +30,7 @@ export abstract class ReffuseNamespace { this.SubRef = this.SubRef.bind(this as any) as any this.SubscribeRefs = this.SubscribeRefs.bind(this as any) as any this.RefState = this.RefState.bind(this as any) as any - // this.SubscribeStream = this.SubscribeStream.bind(this as any) as any + this.SubscribeStream = this.SubscribeStream.bind(this as any) as any } @@ -592,16 +592,31 @@ export abstract class ReffuseNamespace { return props.children(this.useRefState(props.ref)) } - // SubscribeStream( - // this: ReffuseNamespace, - // props: { - // readonly stream: Stream.Stream - // readonly initialValue?: () => Effect.Effect - // readonly children: (latestValue: InitialA extends A ? Option.Some : Option.Option) => React.ReactNode - // }, - // ): React.ReactNode { - // return props.children(this.useSubscribeStream(props.stream, props.initialValue)) - // } + SubscribeStream( + this: ReffuseNamespace, + props: { + readonly stream: Stream.Stream + readonly children: (latestValue: Option.Option) => React.ReactNode + }, + ): React.ReactNode + SubscribeStream( + this: ReffuseNamespace, + props: { + readonly stream: Stream.Stream + readonly initialValue: () => Effect.Effect + readonly children: (latestValue: Option.Some) => React.ReactNode + }, + ): React.ReactNode + SubscribeStream( + this: ReffuseNamespace, + props: { + readonly stream: Stream.Stream + readonly initialValue?: () => Effect.Effect + readonly children: (latestValue: Option.Some) => React.ReactNode + }, + ): React.ReactNode { + return props.children(this.useSubscribeStream(props.stream, props.initialValue as () => Effect.Effect)) + } }