Skip to content

Commit 6002f71

Browse files
committed
perf(core): small perf improvement for factoryObservable
1 parent ea14185 commit 6002f71

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed

packages/core/src/bind/connectFactoryObservable.ts

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,13 +55,14 @@ export default function connectFactoryObservable<A extends [], O>(
5555

5656
const publicShared$ = new Observable<O>((subscriber) => {
5757
const inCache = cache.get(keys)
58-
const source$ = inCache
59-
? inCache[0] === publicShared$
60-
? sharedObservable$
61-
: inCache[0]
62-
: getSharedObservables$(input)[0]
58+
let source$: BehaviorObservable<O> = sharedObservable$
6359

64-
publicShared$.getValue = source$.getValue
60+
if (!inCache) {
61+
cache.set(keys, result)
62+
} else if (inCache[0] !== publicShared$) {
63+
source$ = inCache[0]
64+
publicShared$.getValue = source$.getValue
65+
}
6566

6667
return source$.subscribe(subscriber)
6768
}) as BehaviorObservable<O>

0 commit comments

Comments
 (0)