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 @@ -117,29 +117,33 @@ export function useBaseQuery<
117117 } )
118118
119119 const suspense = ( ) => {
120- return new Promise < QueryObserverResult < TData , TError > > ( ( resolve ) => {
121- let stopWatch = ( ) => {
122- //noop
123- }
124- const run = ( ) => {
125- if ( defaultedOptions . value . enabled !== false ) {
126- const optimisticResult = observer . getOptimisticResult (
127- defaultedOptions . value ,
128- )
129- if ( optimisticResult . isStale ) {
130- stopWatch ( )
131- resolve ( observer . fetchOptimistic ( defaultedOptions . value ) )
132- } else {
133- stopWatch ( )
134- resolve ( optimisticResult )
120+ return new Promise < QueryObserverResult < TData , TError > > (
121+ ( resolve , reject ) => {
122+ let stopWatch = ( ) => {
123+ //noop
124+ }
125+ const run = ( ) => {
126+ if ( defaultedOptions . value . enabled !== false ) {
127+ const optimisticResult = observer . getOptimisticResult (
128+ defaultedOptions . value ,
129+ )
130+ if ( optimisticResult . isStale ) {
131+ stopWatch ( )
132+ observer
133+ . fetchOptimistic ( defaultedOptions . value )
134+ . then ( resolve , reject )
135+ } else {
136+ stopWatch ( )
137+ resolve ( optimisticResult )
138+ }
135139 }
136140 }
137- }
138141
139- run ( )
142+ run ( )
140143
141- stopWatch = watch ( defaultedOptions , run , { deep : true } )
142- } )
144+ stopWatch = watch ( defaultedOptions , run , { deep : true } )
145+ } ,
146+ )
143147 }
144148
145149 return {
You can’t perform that action at this time.
0 commit comments