@tanstack/solid-query
Advanced tools
Comparing version 5.0.0-alpha.15 to 5.0.0-alpha.16
@@ -61,4 +61,8 @@ 'use strict'; | ||
const query = observer.getCurrentQuery(); | ||
const { | ||
refetch, | ||
...rest | ||
} = store.unwrap(result); | ||
const unwrappedResult = { | ||
...store.unwrap(result), | ||
...rest, | ||
// hydrate() expects a QueryState object, which is similar but not | ||
@@ -80,2 +84,4 @@ // quite the same as a QueryObserverResult object. Thus, for now, we're | ||
if (unwrappedResult.isSuccess) { | ||
// Use of any here is fine | ||
// We cannot include refetch since it is not serializable | ||
resolve(unwrappedResult); | ||
@@ -82,0 +88,0 @@ } |
@@ -60,4 +60,8 @@ import { notifyManager, hydrate, QueryObserver, InfiniteQueryObserver, MutationObserver, QueriesObserver } from '@tanstack/query-core'; | ||
const query = observer.getCurrentQuery(); | ||
const { | ||
refetch, | ||
...rest | ||
} = unwrap(result); | ||
const unwrappedResult = { | ||
...unwrap(result), | ||
...rest, | ||
// hydrate() expects a QueryState object, which is similar but not | ||
@@ -79,2 +83,4 @@ // quite the same as a QueryObserverResult object. Thus, for now, we're | ||
if (unwrappedResult.isSuccess) { | ||
// Use of any here is fine | ||
// We cannot include refetch since it is not serializable | ||
resolve(unwrappedResult); | ||
@@ -81,0 +87,0 @@ } |
@@ -23,4 +23,5 @@ import { hydrate } from '@tanstack/query-core'; | ||
const query = observer.getCurrentQuery(); | ||
const { refetch, ...rest } = unwrap(result); | ||
const unwrappedResult = { | ||
...unwrap(result), | ||
...rest, | ||
// hydrate() expects a QueryState object, which is similar but not | ||
@@ -42,2 +43,4 @@ // quite the same as a QueryObserverResult object. Thus, for now, we're | ||
if (unwrappedResult.isSuccess) { | ||
// Use of any here is fine | ||
// We cannot include refetch since it is not serializable | ||
resolve(unwrappedResult); | ||
@@ -44,0 +47,0 @@ } |
@@ -1,2 +0,2 @@ | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/query-core"),require("solid-js"),require("solid-js/web"),require("solid-js/store")):"function"==typeof define&&define.amd?define(["exports","@tanstack/query-core","solid-js","solid-js/web","solid-js/store"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).index={},e.QueryCore,e.Solid,e.SolidWeb,e.SolidStore)}(this,(function(e,t,r,n,o){"use strict";t.notifyManager.setBatchNotifyFunction(r.batch);const i=r.createContext(void 0),s=e=>{const t=r.useContext(i);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t};function u(e,t){return"function"==typeof e?e(...t):!!e}function a(e,i,a){const c=r.createMemo((()=>s(a?.()))),l=c().defaultQueryOptions(e());l._optimisticResults="optimistic",n.isServer&&(l.retry=!1,l.throwErrors=!0);const d=new i(c(),l),[f,p]=o.createStore(d.getOptimisticResult(l)),y=()=>d.subscribe((e=>{t.notifyManager.batchCalls((()=>{const t={...o.unwrap(e)};h()?.data&&t.data&&!h.loading?(p(t),g(f)):(p(t),C())}))()}));let m=null;const[h,{refetch:C,mutate:g}]=r.createResource((()=>new Promise(((e,r)=>{n.isServer?m=((e,r)=>d.subscribe((n=>{t.notifyManager.batchCalls((()=>{const t=d.getCurrentQuery(),i={...o.unwrap(n),dataUpdateCount:t.state.dataUpdateCount,fetchFailureCount:t.state.fetchFailureCount,fetchFailureReason:t.state.fetchFailureReason,fetchMeta:t.state.fetchMeta,isInvalidated:t.state.isInvalidated};i.isError&&("development"===process.env.NODE_ENV&&console.error(i.error),r(i.error)),i.isSuccess&&e(i)}))()})))(e,r):m||(m=y()),f.isLoading||e(f)}))),{initialValue:f,ssrLoadFrom:e().initialData?"initial":"server",get deferStream(){return e().deferStream},onHydrated(e,r){if(r.value&&t.hydrate(c(),{queries:[{queryKey:l.queryKey,queryHash:l.queryHash,state:r.value}]}),!m){const e={...l};!l.staleTime&&l.initialData||(e.refetchOnMount=!1),d.setOptions(e),p(d.getOptimisticResult(e)),m=y()}}});r.onCleanup((()=>{m&&(m(),m=null)})),r.createComputed(r.on((()=>c().defaultQueryOptions(e())),(()=>d.setOptions(c().defaultQueryOptions(e()))),{defer:!0})),r.createComputed(r.on((()=>f.status),(()=>{if(f.isError&&!f.isFetching&&u(d.options.throwErrors,[f.error,d.getCurrentQuery()]))throw f.error})));return new Proxy(f,{get(e,t){const r=h()?.[t];return void 0!==r?r:Reflect.get(e,t)}})}function c(){}e.QueryClientContext=i,e.QueryClientProvider=e=>(r.onMount((()=>{e.client.mount()})),r.onCleanup((()=>e.client.unmount())),n.createComponent(i.Provider,{get value(){return e.client},get children(){return e.children}})),e.createInfiniteQuery=function(e,n){return a(r.createMemo((()=>e())),t.InfiniteQueryObserver,n)},e.createMutation=function(e,n){const i=s(n?.()),a=new t.MutationObserver(i,e()),l=(e,t)=>{a.mutate(e,t).catch(c)},[d,f]=o.createStore({...a.getCurrentResult(),mutate:l,mutateAsync:a.getCurrentResult().mutate});r.createComputed((()=>{a.setOptions(e())})),r.createComputed(r.on((()=>d.status),(()=>{if(d.isError&&u(a.options.throwErrors,[d.error]))throw d.error})));const p=a.subscribe((e=>{f({...e,mutate:l,mutateAsync:e.mutate})}));return r.onCleanup(p),d},e.createQueries=function(e,n){const i=s(n?.()),u=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t})),a=new t.QueriesObserver(i,u),[c,l]=o.createStore(a.getOptimisticResult(u)),d=a.subscribe((e=>{t.notifyManager.batchCalls((()=>{l(o.unwrap(e))}))()}));return r.onCleanup(d),r.onMount((()=>{a.setQueries(u,{listeners:!1})})),r.createComputed((()=>{const t=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t}));a.setQueries(t)})),c},e.createQuery=function(e,n){return a(r.createMemo((()=>e())),t.QueryObserver,n)},e.useIsFetching=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getQueryCache())),[i,u]=r.createSignal(n().isFetching(e?.())),a=o().subscribe((()=>{u(n().isFetching(e?.()))}));return r.onCleanup(a),i},e.useIsMutating=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getMutationCache())),[i,u]=r.createSignal(n().isMutating(e?.())),a=o().subscribe((t=>{u(n().isMutating(e?.()))}));return r.onCleanup(a),i},e.useQueryClient=s,Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})}))})); | ||
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports,require("@tanstack/query-core"),require("solid-js"),require("solid-js/web"),require("solid-js/store")):"function"==typeof define&&define.amd?define(["exports","@tanstack/query-core","solid-js","solid-js/web","solid-js/store"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).index={},e.QueryCore,e.Solid,e.SolidWeb,e.SolidStore)}(this,(function(e,t,r,n,o){"use strict";t.notifyManager.setBatchNotifyFunction(r.batch);const i=r.createContext(void 0),s=e=>{const t=r.useContext(i);if(e)return e;if(!t)throw new Error("No QueryClient set, use QueryClientProvider to set one");return t};function u(e,t){return"function"==typeof e?e(...t):!!e}function a(e,i,a){const c=r.createMemo((()=>s(a?.()))),l=c().defaultQueryOptions(e());l._optimisticResults="optimistic",n.isServer&&(l.retry=!1,l.throwErrors=!0);const f=new i(c(),l),[d,p]=o.createStore(f.getOptimisticResult(l)),y=()=>f.subscribe((e=>{t.notifyManager.batchCalls((()=>{const t={...o.unwrap(e)};h()?.data&&t.data&&!h.loading?(p(t),g(d)):(p(t),C())}))()}));let m=null;const[h,{refetch:C,mutate:g}]=r.createResource((()=>new Promise(((e,r)=>{n.isServer?m=((e,r)=>f.subscribe((n=>{t.notifyManager.batchCalls((()=>{const t=f.getCurrentQuery(),{refetch:i,...s}=o.unwrap(n),u={...s,dataUpdateCount:t.state.dataUpdateCount,fetchFailureCount:t.state.fetchFailureCount,fetchFailureReason:t.state.fetchFailureReason,fetchMeta:t.state.fetchMeta,isInvalidated:t.state.isInvalidated};u.isError&&("development"===process.env.NODE_ENV&&console.error(u.error),r(u.error)),u.isSuccess&&e(u)}))()})))(e,r):m||(m=y()),d.isLoading||e(d)}))),{initialValue:d,ssrLoadFrom:e().initialData?"initial":"server",get deferStream(){return e().deferStream},onHydrated(e,r){if(r.value&&t.hydrate(c(),{queries:[{queryKey:l.queryKey,queryHash:l.queryHash,state:r.value}]}),!m){const e={...l};!l.staleTime&&l.initialData||(e.refetchOnMount=!1),f.setOptions(e),p(f.getOptimisticResult(e)),m=y()}}});r.onCleanup((()=>{m&&(m(),m=null)})),r.createComputed(r.on((()=>c().defaultQueryOptions(e())),(()=>f.setOptions(c().defaultQueryOptions(e()))),{defer:!0})),r.createComputed(r.on((()=>d.status),(()=>{if(d.isError&&!d.isFetching&&u(f.options.throwErrors,[d.error,f.getCurrentQuery()]))throw d.error})));return new Proxy(d,{get(e,t){const r=h()?.[t];return void 0!==r?r:Reflect.get(e,t)}})}function c(){}e.QueryClientContext=i,e.QueryClientProvider=e=>(r.onMount((()=>{e.client.mount()})),r.onCleanup((()=>e.client.unmount())),n.createComponent(i.Provider,{get value(){return e.client},get children(){return e.children}})),e.createInfiniteQuery=function(e,n){return a(r.createMemo((()=>e())),t.InfiniteQueryObserver,n)},e.createMutation=function(e,n){const i=s(n?.()),a=new t.MutationObserver(i,e()),l=(e,t)=>{a.mutate(e,t).catch(c)},[f,d]=o.createStore({...a.getCurrentResult(),mutate:l,mutateAsync:a.getCurrentResult().mutate});r.createComputed((()=>{a.setOptions(e())})),r.createComputed(r.on((()=>f.status),(()=>{if(f.isError&&u(a.options.throwErrors,[f.error]))throw f.error})));const p=a.subscribe((e=>{d({...e,mutate:l,mutateAsync:e.mutate})}));return r.onCleanup(p),f},e.createQueries=function(e,n){const i=s(n?.()),u=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t})),a=new t.QueriesObserver(i,u),[c,l]=o.createStore(a.getOptimisticResult(u)),f=a.subscribe((e=>{t.notifyManager.batchCalls((()=>{l(o.unwrap(e))}))()}));return r.onCleanup(f),r.onMount((()=>{a.setQueries(u,{listeners:!1})})),r.createComputed((()=>{const t=e().queries.map((e=>{const t=i.defaultQueryOptions(e);return t._optimisticResults="optimistic",t}));a.setQueries(t)})),c},e.createQuery=function(e,n){return a(r.createMemo((()=>e())),t.QueryObserver,n)},e.useIsFetching=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getQueryCache())),[i,u]=r.createSignal(n().isFetching(e?.())),a=o().subscribe((()=>{u(n().isFetching(e?.()))}));return r.onCleanup(a),i},e.useIsMutating=function(e,t){const n=r.createMemo((()=>s(t?.()))),o=r.createMemo((()=>n().getMutationCache())),[i,u]=r.createSignal(n().isMutating(e?.())),a=o().subscribe((t=>{u(n().isMutating(e?.()))}));return r.onCleanup(a),i},e.useQueryClient=s,Object.keys(t).forEach((function(r){"default"===r||e.hasOwnProperty(r)||Object.defineProperty(e,r,{enumerable:!0,get:function(){return t[r]}})}))})); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "@tanstack/solid-query", | ||
"version": "5.0.0-alpha.15", | ||
"version": "5.0.0-alpha.16", | ||
"description": "Primitives for managing, caching and syncing asynchronous and remote data in Solid", | ||
@@ -5,0 +5,0 @@ "author": "tannerlinsley", |
@@ -67,4 +67,5 @@ /* eslint-disable @typescript-eslint/no-unnecessary-condition */ | ||
const query = observer.getCurrentQuery() | ||
const { refetch, ...rest } = unwrap(result) | ||
const unwrappedResult = { | ||
...unwrap(result), | ||
...rest, | ||
@@ -88,3 +89,5 @@ // hydrate() expects a QueryState object, which is similar but not | ||
if (unwrappedResult.isSuccess) { | ||
resolve(unwrappedResult) | ||
// Use of any here is fine | ||
// We cannot include refetch since it is not serializable | ||
resolve(unwrappedResult as any) | ||
} | ||
@@ -91,0 +94,0 @@ })() |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
815041
20890