mirror of
https://github.com/re-rxjs/react-rxjs.git
synced 2025-12-08 18:01:51 +00:00
chore: improve useObservable implementation
This commit is contained in:
parent
e750dd13b8
commit
ad1c39e19c
@ -20,16 +20,11 @@ const useObservable = <O, I>(
|
||||
? undefined
|
||||
: setTimeout(setState, suspenseTime, initialValue)
|
||||
|
||||
const stopInitialState = () => {
|
||||
if (!timeoutToken) return
|
||||
timeoutToken = clearTimeout(timeoutToken) as undefined
|
||||
}
|
||||
|
||||
const subscription = delayUnsubscription(unsubscribeGraceTime)(
|
||||
source$,
|
||||
).subscribe(nextState => {
|
||||
setState(nextState as any)
|
||||
stopInitialState()
|
||||
timeoutToken = timeoutToken && (clearTimeout(timeoutToken) as undefined)
|
||||
})
|
||||
|
||||
return () => subscription.unsubscribe()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user