Query & Mutation Builders now doesn't create a new instance

This commit is contained in:
Kingkor Roy Tirtho
2022-07-12 03:15:44 +06:00
parent 89272d5c00
commit 88841e71f8
10 changed files with 40 additions and 27 deletions
@@ -1 +1 @@
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.5/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.5/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]}],"date_created":"2022-07-08 04:37:56.711440","version":"3.0.1"}
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.5/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.5/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.2/","dependencies":[]}]},"dependencyGraph":[{"name":"connectivity_plus","dependencies":["connectivity_plus_linux","connectivity_plus_macos","connectivity_plus_web","connectivity_plus_windows"]},{"name":"connectivity_plus_linux","dependencies":[]},{"name":"connectivity_plus_macos","dependencies":[]},{"name":"connectivity_plus_web","dependencies":[]},{"name":"connectivity_plus_windows","dependencies":[]}],"date_created":"2022-07-12 03:10:11.860962","version":"3.0.1"}
@@ -27,7 +27,7 @@ Mutation<T, V> useMutation<T extends Object, V>({
final init = useCallback(() {
mutation.value = queryBowl.addMutation<T, V>(
mutation.value,
job,
onData: onData,
onError: onError,
onMutate: onMutate,
@@ -55,10 +55,6 @@ Mutation<T, V> useMutation<T extends Object, V>({
useEffect(() {
if (oldJob != null && oldJob.mutationKey != job.mutationKey) {
disposeMutation();
mutation.value = Mutation<T, V>.fromOptions(
job,
queryBowl: queryBowl,
);
init();
} else {
if (oldOnData != onData && oldOnData != null) {
@@ -33,7 +33,8 @@ Query<T, Outside> useQuery<T extends Object, Outside>({
final init = useCallback(() {
query.value = queryBowl.addQuery<T, Outside>(
query.value,
job,
externalData: externalData,
key: uKey,
onData: onData,
onError: onError,
@@ -46,7 +47,7 @@ Query<T, Outside> useQuery<T extends Object, Outside>({
hasExternalDataChanged
? query.value.refetch()
: query.value.fetch();
}, [queryBowl, query.value, uKey, onData, onError, job]);
}, [queryBowl, query.value, uKey, onData, onError, job, externalData]);
final disposeQuery = useCallback(() {
query.value.unmount(uKey);
@@ -64,11 +65,6 @@ Query<T, Outside> useQuery<T extends Object, Outside>({
final hasOnDataChanged = oldOnData != onData && oldOnData != null;
if (oldJob != null && oldJob.queryKey != job.queryKey) {
disposeQuery();
query.value = Query.fromOptions(
job,
externalData: externalData,
queryBowl: queryBowl,
);
init();
} else if (oldExternalData != null &&
externalData != null &&