mirror of
https://github.com/re-rxjs/react-rxjs.git
synced 2025-12-08 18:01:51 +00:00
v0.1.3
This commit is contained in:
parent
529e19501d
commit
a1c64db22f
2
package-lock.json
generated
2
package-lock.json
generated
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@josepot/react-rxjs",
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
{
|
||||
"version": "0.1.2",
|
||||
"version": "0.1.3",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git+https://github.com/josepot/react-rxjs.git"
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
import { useEffect, useState } from "react"
|
||||
import { Observable, of } from "rxjs"
|
||||
import { finalize, delay, takeUntil } from "rxjs/operators"
|
||||
import { delay, takeUntil } from "rxjs/operators"
|
||||
import {
|
||||
StaticObservableOptions,
|
||||
defaultStaticOptions,
|
||||
@ -43,10 +43,9 @@ export function connectFactoryObservable<
|
||||
}
|
||||
|
||||
const reactObservable$ = getObservable(...input).pipe(
|
||||
finalize(() => {
|
||||
distinctShareReplay(compare, () => {
|
||||
cache.delete(key)
|
||||
}),
|
||||
distinctShareReplay(compare),
|
||||
)
|
||||
|
||||
cache.set(key, reactObservable$)
|
||||
|
||||
@ -1,12 +1,19 @@
|
||||
import { Observable, ReplaySubject, concat, NEVER } from "rxjs"
|
||||
import { distinctUntilChanged, multicast, refCount } from "rxjs/operators"
|
||||
import {
|
||||
distinctUntilChanged,
|
||||
multicast,
|
||||
refCount,
|
||||
finalize,
|
||||
} from "rxjs/operators"
|
||||
|
||||
const distinctShareReplay = <T>(compare?: (a: T, b: T) => boolean) => (
|
||||
source$: Observable<T>,
|
||||
): Observable<T> =>
|
||||
const distinctShareReplay = <T>(
|
||||
compare?: (a: T, b: T) => boolean,
|
||||
tearDown?: () => void,
|
||||
) => (source$: Observable<T>): Observable<T> =>
|
||||
source$.pipe(
|
||||
distinctUntilChanged(compare),
|
||||
innerSource => concat(innerSource, NEVER),
|
||||
tearDown ? finalize(tearDown) : x => x,
|
||||
multicast(() => new ReplaySubject<T>(1)),
|
||||
refCount(),
|
||||
)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user