diff --git a/.changeset/nervous-ads-develop.md b/.changeset/nervous-ads-develop.md
new file mode 100644
index 0000000..2d43526
--- /dev/null
+++ b/.changeset/nervous-ads-develop.md
@@ -0,0 +1,5 @@
+---
+"@effect-rx/rx": patch
+---
+
+add Rx.subRef & runtime.subRef constructor
diff --git a/docs/rx-react/index.ts.md b/docs/rx-react/index.ts.md
index 3feb65c..b42d11c 100644
--- a/docs/rx-react/index.ts.md
+++ b/docs/rx-react/index.ts.md
@@ -95,7 +95,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const useRxRefresh: (rx: any) => () => void
+export declare const useRxRefresh: (rx: Rx.Rx & Rx.Refreshable) => () => void
```
Added in v1.0.0
@@ -116,8 +116,8 @@ Added in v1.0.0
```ts
export declare const useRxSetPromise: (
- rx: Rx.Writable, W>
-) => (_: W) => Promise>
+ rx: Rx.Writable, W>
+) => (_: W) => Promise>
```
Added in v1.0.0
@@ -141,10 +141,10 @@ Added in v1.0.0
**Signature**
```ts
-export declare const useRxSuspense: (
- rx: Rx.Rx>,
+export declare const useRxSuspense: (
+ rx: Rx.Rx>,
options?: { readonly suspendOnWaiting?: boolean }
-) => any
+) => Result.Success | Result.Failure
```
Added in v1.0.0
@@ -154,10 +154,10 @@ Added in v1.0.0
**Signature**
```ts
-export declare const useRxSuspenseSuccess: (
- rx: Rx.Rx>,
+export declare const useRxSuspenseSuccess: (
+ rx: Rx.Rx>,
options?: { readonly suspendOnWaiting?: boolean }
-) => Result.Success
+) => Result.Success
```
Added in v1.0.0
diff --git a/docs/rx/Result.ts.md b/docs/rx/Result.ts.md
index 0b0b5eb..55098e8 100644
--- a/docs/rx/Result.ts.md
+++ b/docs/rx/Result.ts.md
@@ -43,6 +43,7 @@ Added in v1.0.0
- [refinements](#refinements)
- [isFailure](#isfailure)
- [isInitial](#isinitial)
+ - [isInterrupted](#isinterrupted)
- [isNotInitial](#isnotinitial)
- [isSuccess](#issuccess)
- [type ids](#type-ids)
@@ -58,7 +59,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const cause: (self: Result) => Option.Option>
+export declare const cause: (self: Result) => Option.Option>
```
Added in v1.0.0
@@ -68,7 +69,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const value: (self: Result) => Option.Option
+export declare const value: (self: Result) => Option.Option
```
Added in v1.0.0
@@ -80,8 +81,10 @@ Added in v1.0.0
**Signature**
```ts
-export declare const map: ((f: (a: A) => B) => (self: Result) => Result) &
- ((self: Result, f: (a: A) => B) => Result)
+export declare const map: {
+ (f: (a: A) => B): (self: Result) => Result
+ (self: Result, f: (a: A) => B): Result
+}
```
Added in v1.0.0
@@ -91,7 +94,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const toExit: (self: Result) => Exit.Exit
+export declare const toExit: (self: Result) => Exit.Exit
```
Added in v1.0.0
@@ -103,11 +106,11 @@ Added in v1.0.0
**Signature**
```ts
-export declare const fail: (
+export declare const fail: (
error: E,
previousData?: Option.Option | undefined,
waiting?: boolean
-) => Failure
+) => Failure
```
Added in v1.0.0
@@ -117,11 +120,11 @@ Added in v1.0.0
**Signature**
```ts
-export declare const failWithPrevious: (
+export declare const failWithPrevious: (
error: E,
- previous: Option.Option>,
+ previous: Option.Option>,
waiting?: boolean
-) => Failure
+) => Failure
```
Added in v1.0.0
@@ -131,11 +134,11 @@ Added in v1.0.0
**Signature**
```ts
-export declare const failure: (
+export declare const failure: (
cause: Cause.Cause,
previousValue?: Option.Option,
waiting?: boolean
-) => Failure
+) => Failure
```
Added in v1.0.0
@@ -145,11 +148,11 @@ Added in v1.0.0
**Signature**
```ts
-export declare const failureWithPrevious: (
+export declare const failureWithPrevious: (
cause: Cause.Cause,
- previous: Option.Option>,
+ previous: Option.Option>,
waiting?: boolean
-) => Failure
+) => Failure
```
Added in v1.0.0
@@ -159,7 +162,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const fromExit: (exit: Exit.Exit) => Success | Failure
+export declare const fromExit: (exit: Exit.Exit) => Success | Failure
```
Added in v1.0.0
@@ -169,10 +172,10 @@ Added in v1.0.0
**Signature**
```ts
-export declare const fromExitWithPrevious: (
- exit: Exit.Exit,
- previous: Option.Option>
-) => Success | Failure
+export declare const fromExitWithPrevious: (
+ exit: Exit.Exit,
+ previous: Option.Option>
+) => Success | Failure
```
Added in v1.0.0
@@ -182,7 +185,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const initial: (waiting?: boolean) => Initial
+export declare const initial: (waiting?: boolean) => Initial
```
Added in v1.0.0
@@ -194,8 +197,8 @@ Added in v1.0.0
```ts
export declare const replacePrevious: , XE, A>(
self: R,
- previous: Option.Option>
-) => Result.With, A>
+ previous: Option.Option>
+) => Result.With>
```
Added in v1.0.0
@@ -205,7 +208,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const success: (value: A, waiting?: boolean) => Success
+export declare const success: (value: A, waiting?: boolean) => Success
```
Added in v1.0.0
@@ -225,7 +228,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const waitingFrom: (previous: Option.Option>) => Result
+export declare const waitingFrom: (previous: Option.Option>) => Result
```
Added in v1.0.0
@@ -237,7 +240,7 @@ Added in v1.0.0
**Signature**
```ts
-export interface Failure extends Result.Proto {
+export interface Failure extends Result.Proto {
readonly _tag: "Failure"
readonly cause: Cause.Cause
readonly previousValue: Option.Option
@@ -251,7 +254,7 @@ Added in v1.0.0
**Signature**
```ts
-export interface Initial extends Result.Proto {
+export interface Initial extends Result.Proto {
readonly _tag: "Initial"
}
```
@@ -263,7 +266,7 @@ Added in v1.0.0
**Signature**
```ts
-export type Result = Initial | Success | Failure
+export type Result = Initial | Success | Failure
```
Added in v1.0.0
@@ -277,7 +280,7 @@ Added in v1.0.0
**Signature**
```ts
-export interface Proto extends Pipeable, Data.Case {
+export interface Proto extends Pipeable {
readonly [TypeId]: {
readonly E: (_: never) => E
readonly A: (_: never) => A
@@ -293,7 +296,7 @@ Added in v1.0.0
**Signature**
```ts
-export type InferA> = R extends Result ? A : never
+export type InferA> = R extends Result ? A : never
```
Added in v1.0.0
@@ -303,7 +306,7 @@ Added in v1.0.0
**Signature**
```ts
-export type InferE> = R extends Result ? E : never
+export type InferE> = R extends Result ? E : never
```
Added in v1.0.0
@@ -313,13 +316,13 @@ Added in v1.0.0
**Signature**
```ts
-export type With, E, A> =
- R extends Initial
- ? Initial
- : R extends Success
- ? Success
- : R extends Failure
- ? Failure
+export type With, A, E> =
+ R extends Initial
+ ? Initial
+ : R extends Success
+ ? Success
+ : R extends Failure
+ ? Failure
: never
```
@@ -330,7 +333,7 @@ Added in v1.0.0
**Signature**
```ts
-export interface Success extends Result.Proto {
+export interface Success extends Result.Proto {
readonly _tag: "Success"
readonly value: A
}
@@ -345,7 +348,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const isFailure: (result: Result) => result is Failure
+export declare const isFailure: (result: Result) => result is Failure
```
Added in v1.0.0
@@ -355,7 +358,17 @@ Added in v1.0.0
**Signature**
```ts
-export declare const isInitial: (result: Result) => result is Initial
+export declare const isInitial: (result: Result) => result is Initial
+```
+
+Added in v1.0.0
+
+## isInterrupted
+
+**Signature**
+
+```ts
+export declare const isInterrupted: (result: Result) => result is Failure
```
Added in v1.0.0
@@ -365,7 +378,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const isNotInitial: (result: Result) => result is Success | Failure
+export declare const isNotInitial: (result: Result) => result is Success | Failure
```
Added in v1.0.0
@@ -375,7 +388,7 @@ Added in v1.0.0
**Signature**
```ts
-export declare const isSuccess: (result: Result) => result is Success
+export declare const isSuccess: (result: Result) => result is Success
```
Added in v1.0.0
diff --git a/docs/rx/Rx.ts.md b/docs/rx/Rx.ts.md
index a91f92f..8c5abc8 100644
--- a/docs/rx/Rx.ts.md
+++ b/docs/rx/Rx.ts.md
@@ -31,6 +31,7 @@ Added in v1.0.0
- [make](#make)
- [pull](#pull)
- [readable](#readable)
+ - [subRef](#subref)
- [writable](#writable)
- [context](#context-1)
- [Context (interface)](#context-interface)
@@ -127,19 +128,21 @@ Added in v1.0.0
**Signature**
```ts
-export declare const mapResult: (>, B>(
- f: (_: Result.Result.InferA>) => B
-) => (
- self: R
-) => [R] extends [Writable]
- ? Writable>, B>, RW>
- : Rx>, B>>) &
- (>, B>(
- self: R,
+export declare const mapResult: {
+ >, B>(
f: (_: Result.Result.InferA>) => B
+ ): (
+ self: R
) => [R] extends [Writable]
- ? Writable>, B>, RW>
- : Rx>, B>>)
+ ? Writable>>, RW>
+ : Rx>>>
+ >, B>(
+ self: R,
+ f: (_: Result.Result.InferA>) => B
+ ): [R] extends [Writable]
+ ? Writable>>, RW>
+ : Rx>>>
+}
```
Added in v1.0.0
@@ -174,18 +177,18 @@ Added in v1.0.0
```ts
export declare const withFallback: {
(
- fallback: Rx>
+ fallback: Rx>
): >>(
self: R
) => [R] extends [Writable]
- ? Writable>, A2 | Result.Result.InferA>>, RW>
- : Rx>, A2 | Result.Result.InferA>>>
- >, E2, A2>(
+ ? Writable>, E2 | Result.Result.InferE>>, RW>
+ : Rx>, E2 | Result.Result.InferE>>>
+ >, A2, E2>(
self: R,
- fallback: Rx>
+ fallback: Rx>
): [R] extends [Writable]
- ? Writable>, A2 | Result.Result.InferA>>, RW>
- : Rx>, A2 | Result.Result.InferA>>>
+ ? Writable>, E2 | Result.Result.InferE>>, RW>
+ : Rx>, E2 | Result.Result.InferE>>>
}
```
@@ -211,9 +214,9 @@ Added in v1.0.0
**Signature**
```ts
-export declare const context: () => (
- create: Layer.Layer | Rx.Read>
-) => RxRuntime
+export declare const context: () => (
+ create: Layer.Layer | Rx.Read>
+) => RxRuntime
```
Added in v1.0.0
@@ -235,13 +238,13 @@ Added in v1.0.0
```ts
export declare const fn: {
(
- fn: Rx.ReadFn>,
+ fn: Rx.ReadFn>,
options?: { readonly initialValue?: A | undefined } | undefined
- ): RxResultFn extends true ? void : Arg>
+ ): RxResultFn extends true ? void : Arg, A, E>
(
- fn: Rx.ReadFn>,
+ fn: Rx.ReadFn>,
options?: { readonly initialValue?: A | undefined } | undefined
- ): RxResultFn extends true ? void : Arg>
+ ): RxResultFn extends true ? void : Arg, A, E | NoSuchElementException>
}
```
@@ -266,22 +269,22 @@ Added in v1.0.0
```ts
export declare const make: {
- (
- effect: Effect.Effect,
+ (
+ effect: Effect.Effect,
options?: { readonly initialValue?: A | undefined } | undefined
- ): Rx>
- (
- create: Rx.Read>,
+ ): Rx>
+ (
+ create: Rx.Read>,
options?: { readonly initialValue?: A | undefined } | undefined
- ): Rx>
- (
- stream: Stream.Stream,
+ ): Rx>
+ (
+ stream: Stream.Stream,
options?: { readonly initialValue?: A | undefined } | undefined
- ): Rx>
- (
- create: Rx.Read>,
+ ): Rx>
+ (
+ create: Rx.Read>,
options?: { readonly initialValue?: A | undefined } | undefined
- ): Rx>
+ ): Rx>
(create: Rx.Read): Rx
(initialValue: A): Writable
}
@@ -294,12 +297,12 @@ Added in v1.0.0
**Signature**
```ts
-export declare const pull: (
- create: Stream.Stream | Rx.Read>,
+export declare const pull: (
+ create: Stream.Stream | Rx.Read>,
options?:
| { readonly disableAccumulation?: boolean | undefined; readonly initialValue?: readonly A[] | undefined }
| undefined
-) => Writable, void>
+) => Writable, void>
```
Added in v1.0.0
@@ -314,6 +317,23 @@ export declare const readable: (read: Rx.Read, refresh?: Rx.Refresh) => Rx
Added in v1.0.0
+## subRef
+
+**Signature**
+
+```ts
+export declare const subRef: {
+ (ref: SubscriptionRef.SubscriptionRef | Rx.Read>): Writable
+ (
+ effect:
+ | Effect.Effect, E, never>
+ | Rx.Read, E, never>>
+ ): Writable, A>
+}
+```
+
+Added in v1.0.0
+
## writable
**Signature**
@@ -334,33 +354,33 @@ Added in v1.0.0
export interface Context {
(rx: Rx): A
readonly get: (rx: Rx) => A
- readonly result: (rx: Rx>) => Exit.Exit
+ readonly result: