Skip to content

Commit 38b0c01

Browse files
authored
refactor(sdk): Remove obsolete onError index parameter (#2921)
Removed the `index` parameter from `onError` signal. It was not used by any component. ## Future improvements - `MsgChainUtils#onError` has a `StreamMessage` parameter, which is not used. We should remove the parameter or start to use it. (I.e. investigate if we should remove the whole `onError` listener in `createMessagePipeline()` if the `ignoreMessages` handling is no longer needed.)
1 parent 7465d20 commit 38b0c01

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

packages/sdk/src/subscribe/MessageStream.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ export class MessageStream implements AsyncIterable<Message> {
2424
/** @internal */
2525
onBeforeFinally: Signal<[]>
2626
/** @internal */
27-
onError: Signal<[Error, (StreamMessage | undefined)?, (number | undefined)?]>
27+
onError: Signal<[Error, (StreamMessage | undefined)?]>
2828

2929
/** @internal */
3030
constructor(pipeline?: PushPipeline<StreamMessage, StreamMessage>) {

packages/sdk/src/subscribe/MsgChainUtil.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import { Signal } from './../utils/Signal'
55

66
type ProcessMessageFn = (streamMessage: StreamMessage) => Promise<StreamMessage>
77

8-
type OnError = Signal<[Error, StreamMessage?, number?]>
8+
type OnError = Signal<[Error, StreamMessage?]> // TODO could remove the StreamMessage parameter or use it?
99

1010
class MsgChainProcessor {
1111

packages/sdk/src/utils/GeneratorUtils.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ export type GeneratorForEach<InType> = MaybeAsync<(value: InType, index: number,
44
export type GeneratorFilter<InType> = MaybeAsync<(value: InType, index: number, src: AsyncGenerator<InType>) => any>
55
export type GeneratorMap<InType, OutType> = (value: InType, index: number, src: AsyncGenerator<InType>) => OutType | Promise<OutType>
66

7-
type OnError<ValueType> = (err: Error, value: ValueType, index: number) => Promise<any> | any
7+
type OnError<ValueType> = (err: Error, value: ValueType) => Promise<any> | any
88

99
const noopConsume = async (src: AsyncGenerator) => {
1010
// eslint-disable-next-line no-underscore-dangle
@@ -29,7 +29,7 @@ export async function* forEach<InType>(
2929
await fn(v, index, src)
3030
} catch (err) {
3131
if (onError) {
32-
await onError(err, v, index)
32+
await onError(err, v)
3333
continue
3434
} else {
3535
throw err
@@ -55,7 +55,7 @@ export async function* map<InType, OutType>(
5555
yield await fn(v, index, src)
5656
} catch (err) {
5757
if (onError) {
58-
await onError(err, v, index)
58+
await onError(err, v)
5959
continue
6060
} else {
6161
throw err
@@ -81,7 +81,7 @@ export async function* filter<InType>(
8181
ok = await fn(v, index, src)
8282
} catch (err) {
8383
if (onError) {
84-
await onError(err, v, index)
84+
await onError(err, v)
8585
continue
8686
} else {
8787
throw err

packages/sdk/src/utils/Pipeline.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ export class Pipeline<InType, OutType = InType> implements IPipeline<InType, Out
103103

104104
onMessage = Signal.create<[OutType]>()
105105

106-
onError = ErrorSignal.create<[Error, (InType | OutType)?, number?]>()
106+
onError = ErrorSignal.create<[Error, (InType | OutType)?]>()
107107

108108
filter(fn: G.GeneratorFilter<OutType>): Pipeline<InType, OutType> {
109109
return this.pipe((src) => G.filter(src, fn, this.onError.trigger))

0 commit comments

Comments
 (0)