Skip to content

Commit

Permalink
remove Result.Waiting state (#74)
Browse files Browse the repository at this point in the history
  • Loading branch information
tim-smart authored Nov 9, 2023
1 parent 57a2162 commit 1495465
Show file tree
Hide file tree
Showing 6 changed files with 220 additions and 348 deletions.
5 changes: 5 additions & 0 deletions .changeset/sharp-penguins-relax.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@effect-rx/rx": minor
---

remove Result.Waiting state
182 changes: 54 additions & 128 deletions docs/rx/Result.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ Added in v1.0.0

- [accessors](#accessors)
- [cause](#cause)
- [noWaiting](#nowaiting)
- [value](#value)
- [combinators](#combinators)
- [map](#map)
Expand All @@ -27,31 +26,24 @@ Added in v1.0.0
- [fromExit](#fromexit)
- [fromExitWithPrevious](#fromexitwithprevious)
- [initial](#initial)
- [replacePrevious](#replaceprevious)
- [success](#success)
- [waiting](#waiting)
- [waitingFrom](#waitingfrom)
- [models](#models)
- [Failure (interface)](#failure-interface)
- [Initial (interface)](#initial-interface)
- [Loading (interface)](#loading-interface)
- [NoWaiting (type alias)](#nowaiting-type-alias)
- [Refreshing (interface)](#refreshing-interface)
- [Result (type alias)](#result-type-alias)
- [Result (namespace)](#result-namespace)
- [Proto (interface)](#proto-interface)
- [Failure (type alias)](#failure-type-alias)
- [Success (type alias)](#success-type-alias)
- [Retrying (interface)](#retrying-interface)
- [InferA (type alias)](#infera-type-alias)
- [InferE (type alias)](#infere-type-alias)
- [With (type alias)](#with-type-alias)
- [Success (interface)](#success-interface)
- [Waiting (type alias)](#waiting-type-alias)
- [refinements](#refinements)
- [isFailure](#isfailure)
- [isInitial](#isinitial)
- [isLoading](#isloading)
- [isRefreshing](#isrefreshing)
- [isRetrying](#isretrying)
- [isSuccess](#issuccess)
- [isWaiting](#iswaiting)
- [type ids](#type-ids)
- [TypeId](#typeid)
- [TypeId (type alias)](#typeid-type-alias)
Expand All @@ -65,17 +57,7 @@ Added in v1.0.0
**Signature**

```ts
export declare const cause: <E, A>(result: Result<E, A>) => Option.Option<Cause.Cause<E>>
```
Added in v1.0.0
## noWaiting
**Signature**
```ts
export declare const noWaiting: <E, A>(result: Result<E, A>) => NoWaiting<E, A>
export declare const cause: <E, A>(self: Result<E, A>) => Option.Option<Cause.Cause<E>>
```
Added in v1.0.0
Expand All @@ -85,7 +67,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const value: <E, A>(result: Result<E, A>) => Option.Option<A>
export declare const value: <E, A>(self: Result<E, A>) => Option.Option<A>
```
Added in v1.0.0
Expand Down Expand Up @@ -120,7 +102,11 @@ Added in v1.0.0
**Signature**
```ts
export declare const fail: <E, A>(error: E, previousData?: Option.Option<A> | undefined) => Failure<E, A>
export declare const fail: <E, A>(
error: E,
previousData?: Option.Option<A> | undefined,
waiting?: boolean
) => Failure<E, A>
```
Added in v1.0.0
Expand All @@ -130,7 +116,11 @@ Added in v1.0.0
**Signature**
```ts
export declare const failWithPrevious: <E, A>(error: E, previous: Option.Option<Result<E, A>>) => Failure<E, A>
export declare const failWithPrevious: <E, A>(
error: E,
previous: Option.Option<Result<E, A>>,
waiting?: boolean
) => Failure<E, A>
```
Added in v1.0.0
Expand All @@ -140,7 +130,11 @@ Added in v1.0.0
**Signature**
```ts
export declare const failure: <E, A>(cause: Cause.Cause<E>, previousValue?: Option.Option<A>) => Failure<E, A>
export declare const failure: <E, A>(
cause: Cause.Cause<E>,
previousValue?: Option.Option<A>,
waiting?: boolean
) => Failure<E, A>
```
Added in v1.0.0
Expand All @@ -152,7 +146,8 @@ Added in v1.0.0
```ts
export declare const failureWithPrevious: <E, A>(
cause: Cause.Cause<E>,
previous: Option.Option<Result<E, A>>
previous: Option.Option<Result<E, A>>,
waiting?: boolean
) => Failure<E, A>
```
Expand Down Expand Up @@ -186,7 +181,20 @@ Added in v1.0.0
**Signature**
```ts
export declare const initial: <E, A>() => Initial<E, A>
export declare const initial: <E, A>(waiting?: boolean) => Initial<E, A>
```
Added in v1.0.0
## replacePrevious
**Signature**
```ts
export declare const replacePrevious: <R extends Result<any, any>, XE, A>(
self: R,
previous: Option.Option<Result<XE, A>>
) => Result.With<R, Result.InferE<R>, A>
```
Added in v1.0.0
Expand All @@ -196,7 +204,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const success: <E, A>(value: A) => Success<E, A>
export declare const success: <E, A>(value: A, waiting?: boolean) => Success<E, A>
```
Added in v1.0.0
Expand All @@ -206,7 +214,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const waiting: <E, A>(previous: Initial<E, A> | Success<E, A> | Failure<E, A>) => Waiting<E, A>
export declare const waiting: <R extends Result<any, any>>(self: R) => R
```
Added in v1.0.0
Expand All @@ -216,7 +224,7 @@ Added in v1.0.0
**Signature**
```ts
export declare const waitingFrom: <E, A>(previous: Option.Option<Result<E, A>>) => Waiting<E, A>
export declare const waitingFrom: <E, A>(previous: Option.Option<Result<E, A>>) => Result<E, A>
```
Added in v1.0.0
Expand Down Expand Up @@ -249,48 +257,12 @@ export interface Initial<E, A> extends Result.Proto<E, A> {

Added in v1.0.0

## Loading (interface)

**Signature**

```ts
export interface Loading<E, A> extends Result.Proto<E, A> {
readonly _tag: 'Waiting'
readonly previous: Initial<E, A>
}
```

Added in v1.0.0

## NoWaiting (type alias)

**Signature**

```ts
export type NoWaiting<E, A> = Initial<E, A> | Success<E, A> | Failure<E, A>
```
Added in v1.0.0
## Refreshing (interface)
**Signature**
```ts
export interface Refreshing<E, A> extends Result.Proto<E, A> {
readonly _tag: 'Waiting'
readonly previous: Success<E, A>
}
```

Added in v1.0.0

## Result (type alias)

**Signature**

```ts
export type Result<E, A> = Initial<E, A> | Waiting<E, A> | Success<E, A> | Failure<E, A>
export type Result<E, A> = Initial<E, A> | Success<E, A> | Failure<E, A>
```
Added in v1.0.0
Expand All @@ -309,40 +281,44 @@ export interface Proto<E, A> extends Pipeable, Data.Case {
readonly E: (_: never) => E
readonly A: (_: never) => A
}
readonly waiting: boolean
}
```

Added in v1.0.0

### Failure (type alias)
### InferA (type alias)

**Signature**

```ts
export type Failure<R extends Result<any, any>> = R extends Result<infer E, infer _> ? E : never
export type InferA<R extends Result<any, any>> = R extends Result<infer _, infer A> ? A : never
```
Added in v1.0.0
### Success (type alias)
### InferE (type alias)
**Signature**
```ts
export type Success<R extends Result<any, any>> = R extends Result<infer _, infer A> ? A : never
export type InferE<R extends Result<any, any>> = R extends Result<infer E, infer _> ? E : never
```
Added in v1.0.0
## Retrying (interface)
### With (type alias)
**Signature**
```ts
export interface Retrying<E, A> extends Result.Proto<E, A> {
readonly _tag: 'Waiting'
readonly previous: Failure<E, A>
}
export type With<R extends Result<any, any>, E, A> = R extends Initial<infer _E, infer _A>
? Initial<E, A>
: R extends Success<infer _E, infer _A>
? Success<E, A>
: R extends Failure<infer _E, infer _A>
? Failure<E, A>
: never
```
Added in v1.0.0
Expand All @@ -360,16 +336,6 @@ export interface Success<E, A> extends Result.Proto<E, A> {

Added in v1.0.0

## Waiting (type alias)

**Signature**

```ts
export type Waiting<E, A> = Refreshing<E, A> | Retrying<E, A> | Loading<E, A>
```
Added in v1.0.0
# refinements

## isFailure
Expand All @@ -392,36 +358,6 @@ export declare const isInitial: <E, A>(result: Result<E, A>) => result is Initia
Added in v1.0.0
## isLoading
**Signature**
```ts
export declare const isLoading: <E, A>(result: Result<E, A>) => result is Loading<E, A>
```
Added in v1.0.0
## isRefreshing
**Signature**
```ts
export declare const isRefreshing: <E, A>(result: Result<E, A>) => result is Refreshing<E, A>
```
Added in v1.0.0
## isRetrying
**Signature**
```ts
export declare const isRetrying: <E, A>(result: Result<E, A>) => result is Retrying<E, A>
```
Added in v1.0.0
## isSuccess
**Signature**
Expand All @@ -432,16 +368,6 @@ export declare const isSuccess: <E, A>(result: Result<E, A>) => result is Succes
Added in v1.0.0
## isWaiting
**Signature**
```ts
export declare const isWaiting: <E, A>(result: Result<E, A>) => result is Waiting<E, A>
```
Added in v1.0.0
# type ids
## TypeId
Expand Down
20 changes: 10 additions & 10 deletions docs/rx/Rx.ts.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,18 +132,18 @@ Added in v1.0.0
```ts
export declare const mapResult: (<R extends Rx<Result.Result<any, any>>, B>(
f: (_: Result.Result.Success<Rx.Infer<R>>) => B
f: (_: Result.Result.InferA<Rx.Infer<R>>) => B
) => (
self: R
) => [R] extends [Writable<infer _, infer RW>]
? Writable<Result.Result<Result.Result.Failure<Rx.Infer<R>>, B>, RW>
: Rx<Result.Result<Result.Result.Failure<Rx.Infer<R>>, B>>) &
? Writable<Result.Result<Result.Result.InferE<Rx.Infer<R>>, B>, RW>
: Rx<Result.Result<Result.Result.InferE<Rx.Infer<R>>, B>>) &
(<R extends Rx<Result.Result<any, any>>, B>(
self: R,
f: (_: Result.Result.Success<Rx.Infer<R>>) => B
f: (_: Result.Result.InferA<Rx.Infer<R>>) => B
) => [R] extends [Writable<infer _, infer RW>]
? Writable<Result.Result<Result.Result.Failure<Rx.Infer<R>>, B>, RW>
: Rx<Result.Result<Result.Result.Failure<Rx.Infer<R>>, B>>)
? Writable<Result.Result<Result.Result.InferE<Rx.Infer<R>>, B>, RW>
: Rx<Result.Result<Result.Result.InferE<Rx.Infer<R>>, B>>)
```
Added in v1.0.0
Expand Down Expand Up @@ -180,13 +180,13 @@ export declare const withFallback: {
<E2, A2>(fallback: Rx<Result.Result<E2, A2>>): <R extends Rx<Result.Result<any, any>>>(
self: R
) => [R] extends [Writable<infer _, infer RW>]
? Writable<Result.Result<E2 | Result.Result.Failure<Rx.Infer<R>>, A2 | Result.Result.Success<Rx.Infer<R>>>, RW>
: Rx<Result.Result<E2 | Result.Result.Failure<Rx.Infer<R>>, A2 | Result.Result.Success<Rx.Infer<R>>>>
? Writable<Result.Result<E2 | Result.Result.InferE<Rx.Infer<R>>, A2 | Result.Result.InferA<Rx.Infer<R>>>, RW>
: Rx<Result.Result<E2 | Result.Result.InferE<Rx.Infer<R>>, A2 | Result.Result.InferA<Rx.Infer<R>>>>
<R extends Rx<Result.Result<any, any>>, E2, A2>(self: R, fallback: Rx<Result.Result<E2, A2>>): [R] extends [
Writable<infer _, infer RW>
]
? Writable<Result.Result<E2 | Result.Result.Failure<Rx.Infer<R>>, A2 | Result.Result.Success<Rx.Infer<R>>>, RW>
: Rx<Result.Result<E2 | Result.Result.Failure<Rx.Infer<R>>, A2 | Result.Result.Success<Rx.Infer<R>>>>
? Writable<Result.Result<E2 | Result.Result.InferE<Rx.Infer<R>>, A2 | Result.Result.InferA<Rx.Infer<R>>>, RW>
: Rx<Result.Result<E2 | Result.Result.InferE<Rx.Infer<R>>, A2 | Result.Result.InferA<Rx.Infer<R>>>>
}
```
Expand Down
Loading

0 comments on commit 1495465

Please sign in to comment.