File tree Expand file tree Collapse file tree
packages/core/src/internal Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11import { Observable , noop } from "rxjs"
2- import { take , filter , tap } from "rxjs/operators"
32import { SUSPENSE } from "../SUSPENSE"
43import { BehaviorObservable , Action } from "./BehaviorObservable"
54import { EMPTY_VALUE } from "./empty-value"
@@ -67,29 +66,32 @@ const reactEnhancer = <T>(source$: Observable<T>): BehaviorObservable<T> => {
6766 let value :
6867 | typeof EMPTY_VALUE
6968 | { type : Action . Value ; payload : T } = EMPTY_VALUE
69+
7070 promise = {
7171 type : Action . Suspense ,
72- payload : result
73- . pipe (
74- filter ( ( x ) => x !== ( SUSPENSE as any ) ) ,
75- take ( 1 ) ,
76- tap ( {
77- next ( v ) {
72+ payload : new Promise < T > ( ( res ) => {
73+ const subscription = result . subscribe (
74+ ( v ) => {
75+ if ( v !== ( SUSPENSE as any ) ) {
7876 value = { type : Action . Value , payload : v }
79- } ,
80- error ( e ) {
81- error = { type : Action . Error , payload : e }
82- timeoutToken = setTimeout ( ( ) => {
83- error = EMPTY_VALUE
84- } , 50 )
85- } ,
86- } ) ,
77+ subscription && subscription . unsubscribe ( )
78+ res ( v )
79+ }
80+ } ,
81+ ( e ) => {
82+ error = { type : Action . Error , payload : e }
83+ timeoutToken = setTimeout ( ( ) => {
84+ error = EMPTY_VALUE
85+ } , 50 )
86+ res ( )
87+ } ,
8788 )
88- . toPromise ( )
89- . catch ( ( ) => { } )
90- . finally ( ( ) => {
91- promise = undefined
92- } ) ,
89+ if ( value !== EMPTY_VALUE || error !== EMPTY_VALUE ) {
90+ subscription . unsubscribe ( )
91+ }
92+ } ) . finally ( ( ) => {
93+ promise = undefined
94+ } ) ,
9395 }
9496
9597 if ( value !== EMPTY_VALUE ) {
You can’t perform that action at this time.
0 commit comments