File tree Expand file tree Collapse file tree 1 file changed +23
-19
lines changed Expand file tree Collapse file tree 1 file changed +23
-19
lines changed Original file line number Diff line number Diff line change @@ -98,29 +98,33 @@ export function useBaseQuery<
9898 } )
9999
100100 const suspense = ( ) => {
101- return new Promise < QueryObserverResult < TData , TError > > ( ( resolve ) => {
102- let stopWatch = ( ) => {
103- //noop
104- }
105- const run = ( ) => {
106- if ( defaultedOptions . value . enabled !== false ) {
107- const optimisticResult = observer . getOptimisticResult (
108- defaultedOptions . value ,
109- )
110- if ( optimisticResult . isStale ) {
111- stopWatch ( )
112- resolve ( observer . fetchOptimistic ( defaultedOptions . value ) )
113- } else {
114- stopWatch ( )
115- resolve ( optimisticResult )
101+ return new Promise < QueryObserverResult < TData , TError > > (
102+ ( resolve , reject ) => {
103+ let stopWatch = ( ) => {
104+ //noop
105+ }
106+ const run = ( ) => {
107+ if ( defaultedOptions . value . enabled !== false ) {
108+ const optimisticResult = observer . getOptimisticResult (
109+ defaultedOptions . value ,
110+ )
111+ if ( optimisticResult . isStale ) {
112+ stopWatch ( )
113+ observer
114+ . fetchOptimistic ( defaultedOptions . value )
115+ . then ( resolve , reject )
116+ } else {
117+ stopWatch ( )
118+ resolve ( optimisticResult )
119+ }
116120 }
117121 }
118- }
119122
120- run ( )
123+ run ( )
121124
122- stopWatch = watch ( defaultedOptions , run , { deep : true } )
123- } )
125+ stopWatch = watch ( defaultedOptions , run , { deep : true } )
126+ } ,
127+ )
124128 }
125129
126130 return {
You can’t perform that action at this time.
0 commit comments