Skip to content

Commit

Permalink
perf(core): small perf improvement for factoryObservable
Browse files Browse the repository at this point in the history
  • Loading branch information
josepot committed Oct 15, 2020
1 parent ea14185 commit 6002f71
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions packages/core/src/bind/connectFactoryObservable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,14 @@ export default function connectFactoryObservable<A extends [], O>(

const publicShared$ = new Observable<O>((subscriber) => {
const inCache = cache.get(keys)
const source$ = inCache
? inCache[0] === publicShared$
? sharedObservable$
: inCache[0]
: getSharedObservables$(input)[0]
let source$: BehaviorObservable<O> = sharedObservable$

publicShared$.getValue = source$.getValue
if (!inCache) {
cache.set(keys, result)
} else if (inCache[0] !== publicShared$) {
source$ = inCache[0]
publicShared$.getValue = source$.getValue
}

return source$.subscribe(subscriber)
}) as BehaviorObservable<O>
Expand Down

0 comments on commit 6002f71

Please sign in to comment.