Skip to content

Commit a6e90d6

Browse files
committed
feat(bind): nested keys accept optional args
1 parent 794f1e5 commit a6e90d6

File tree

2 files changed

+3
-4
lines changed

2 files changed

+3
-4
lines changed

packages/core/src/bind/connectFactoryObservable.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ class NestedMap<K extends [], V extends Object> {
5252
}
5353
}
5454

55-
const emptyInput = [0]
5655
/**
5756
* Accepts: A factory function that returns an Observable.
5857
*
@@ -87,7 +86,7 @@ export default function connectFactoryObservable<A extends [], O>(
8786
const getSharedObservables$ = (
8887
input: A,
8988
): [Observable<O>, BehaviorObservable<O>] => {
90-
const keys = input.length > 0 ? input : (emptyInput as A)
89+
const keys = ([input.length, ...input] as any) as A
9190
const cachedVal = cache.get(keys)
9291

9392
if (cachedVal !== undefined) {

packages/core/src/bind/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,15 +47,15 @@ export function bind<T>(
4747
* for the first value.
4848
*/
4949
export function bind<
50-
A extends (number | string | boolean | null | Object | Symbol)[],
50+
A extends (number | string | boolean | null | Object | Symbol | undefined)[],
5151
O
5252
>(
5353
getObservable: (...args: A) => Observable<O>,
5454
unsubscribeGraceTime?: number,
5555
): [(...args: A) => Exclude<O, typeof SUSPENSE>, (...args: A) => Observable<O>]
5656

5757
export function bind<
58-
A extends (number | string | boolean | null | Object | Symbol)[],
58+
A extends (number | string | boolean | null | Object | Symbol | undefined)[],
5959
O
6060
>(
6161
obs: ((...args: A) => Observable<O>) | Observable<O>,

0 commit comments

Comments
 (0)