diff --git a/packages/utils/src/partitionByKey.test.ts b/packages/utils/src/partitionByKey.test.ts index 427c1ea..d49e008 100644 --- a/packages/utils/src/partitionByKey.test.ts +++ b/packages/utils/src/partitionByKey.test.ts @@ -14,7 +14,7 @@ describe("partitionByKey", () => { scheduler().run(({ expectObservable, cold }) => { const source = cold("-ab---cd---") const expectedStr = "efg---hi---" - const [result] = partitionByKey( + const [, result] = partitionByKey( source, (v) => v, () => NEVER, @@ -38,7 +38,7 @@ describe("partitionByKey", () => { const c = cold(" 1-|") const expectedStr = "efg--hi-j" const innerStreams = { a, b, c } - const [result] = partitionByKey( + const [, result] = partitionByKey( source, (v) => v, (v$) => @@ -72,7 +72,7 @@ describe("partitionByKey", () => { const expectC = " ------1-|" const innerStreams = { a, b, c } - const [, getInstance$] = partitionByKey( + const [getInstance$] = partitionByKey( source, (v) => v, (v$) => @@ -91,7 +91,7 @@ describe("partitionByKey", () => { it("replays the latest value for each key", () => { const source$ = new Subject() const inner$ = new Subject() - const [, getInstance$] = partitionByKey( + const [getInstance$] = partitionByKey( source$, (v) => v, () => inner$, diff --git a/packages/utils/src/partitionByKey.ts b/packages/utils/src/partitionByKey.ts index 5b4157d..3922547 100644 --- a/packages/utils/src/partitionByKey.ts +++ b/packages/utils/src/partitionByKey.ts @@ -10,17 +10,17 @@ import { collect, getGroupedObservable, split } from "./" * @param keySelector Function that specifies the key for each element in `stream` * @param streamSelector Function to apply to each resulting group * @returns [1, 2] - * 1. A stream with the list of active keys - * 2. A function that accepts a key and returns the stream for the group of that key. + * 1. A function that accepts a key and returns the stream for the group of that key. + * 2. A stream with the list of active keys */ export function partitionByKey( stream: Observable, keySelector: (value: T) => K, streamSelector: (grouped: Observable, key: K) => Observable, -): [Observable, (key: K) => GroupedObservable] { +): [(key: K) => GroupedObservable, Observable] { const source$ = stream.pipe(split(keySelector, streamSelector), collect()) return [ - source$.pipe(map((x) => Array.from(x.keys()))), (key: K) => getGroupedObservable(source$, key), + source$.pipe(map((x) => Array.from(x.keys()))), ] }