Skip to content

Commit 5ed4a59

Browse files
committed
remove NoSuchElementException from Rx.pull
1 parent 8041aed commit 5ed4a59

File tree

3 files changed

+11
-15
lines changed

3 files changed

+11
-15
lines changed

.changeset/plenty-llamas-marry.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@effect-rx/rx": minor
3+
---
4+
5+
remove NoSuchElementException from Rx.pull

docs/rx/Rx.ts.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -576,7 +576,7 @@ export type PullResult<A, E = never> = Result.Result<
576576
readonly done: boolean
577577
readonly items: ReadonlyArray<A>
578578
},
579-
E | NoSuchElementException
579+
E
580580
>
581581
```
582582

packages/rx/src/Rx.ts

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -905,7 +905,7 @@ function makeResultFn<Arg, E, A>(
905905
export type PullResult<A, E = never> = Result.Result<{
906906
readonly done: boolean
907907
readonly items: ReadonlyArray<A>
908-
}, E | NoSuchElementException>
908+
}, E>
909909

910910
/**
911911
* @since 1.0.0
@@ -931,7 +931,7 @@ const makeStreamPullEffect: <A, E>(
931931
create: Stream.Stream<A, E, RxRegistry> | ((get: Context) => Stream.Stream<A, E, RxRegistry>),
932932
options?: { readonly disableAccumulation?: boolean } | undefined
933933
) => Effect.Effect<
934-
Effect.Effect<{ readonly done: boolean; readonly items: Array<A> }, NoSuchElementException | E>,
934+
Effect.Effect<{ readonly done: boolean; readonly items: Array<A> }, E>,
935935
never,
936936
Scope.Scope | RxRegistry
937937
> = Effect.fnUntraced(function*<A, E>(
@@ -965,16 +965,11 @@ const makeStreamPullEffect: <A, E>(
965965
items: Chunk.toReadonlyArray(items)
966966
})
967967
},
968-
onFailure(
969-
cause
970-
): Effect.Effect<{ readonly done: boolean; readonly items: ReadonlyArray<A> }, NoSuchElementException | E> {
968+
onFailure(cause) {
971969
const failure = Cause.failureOption(cause)
972970
if (failure._tag === "None") {
973971
return Effect.failCause(cause as Cause.Cause<never>)
974972
} else if (failure.value._tag === "None") {
975-
if (acc.length === 0) {
976-
return Effect.fail(new NoSuchElementException())
977-
}
978973
return Effect.succeed({
979974
done: true,
980975
items: Chunk.toReadonlyArray(acc)
@@ -988,19 +983,15 @@ const makeStreamPullEffect: <A, E>(
988983
})
989984

990985
const makeStreamPull = <A, E>(
991-
pullRx: Rx<
992-
Result.Result<
993-
Effect.Effect<{ readonly done: boolean; readonly items: Array<A> }, NoSuchElementException | E>
994-
>
995-
>,
986+
pullRx: Rx<Result.Result<Effect.Effect<{ readonly done: boolean; readonly items: Array<A> }, E>>>,
996987
options?: {
997988
readonly initialValue?: ReadonlyArray<A>
998989
}
999990
) => {
1000991
const initialValue: Result.Result<{
1001992
readonly done: boolean
1002993
readonly items: Array<A>
1003-
}, E | NoSuchElementException> = options?.initialValue !== undefined
994+
}, E> = options?.initialValue !== undefined
1004995
? Result.success({ done: false, items: options.initialValue as Array<A> })
1005996
: Result.initial()
1006997

0 commit comments

Comments
 (0)