fix: refetchOnExternalDataChange isn't working #18
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
connectivity_plus=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/
|
||||
connectivity_plus_web=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/
|
||||
connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","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-10-12 22:11:02.991775","version":"3.3.4"}
|
||||
{"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.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","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.5/","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-12-14 11:46:10.170392","version":"3.3.8"}
|
||||
@@ -1,6 +1,6 @@
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
connectivity_plus=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/
|
||||
connectivity_plus_web=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/
|
||||
connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","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-10-12 22:11:06.320813","version":"3.3.4"}
|
||||
{"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.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","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.5/","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-12-14 12:54:36.553871","version":"3.3.8"}
|
||||
@@ -1,5 +1,5 @@
|
||||
sdk.dir=/home/krtirtho/Android/Sdk
|
||||
flutter.sdk=/opt/flutter
|
||||
flutter.sdk=/home/krtirtho/fvm/versions/3.3.5
|
||||
flutter.buildMode=debug
|
||||
flutter.versionName=1.0.0
|
||||
flutter.versionCode=1
|
||||
@@ -1,5 +1,5 @@
|
||||
// This is a generated file; do not edit or check into version control.
|
||||
FLUTTER_ROOT=/opt/flutter
|
||||
FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5
|
||||
FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example
|
||||
COCOAPODS_PARALLEL_CODE_SIGN=true
|
||||
FLUTTER_TARGET=lib/main.dart
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
export "FLUTTER_ROOT=/opt/flutter"
|
||||
export "FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5"
|
||||
export "FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example"
|
||||
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
|
||||
export "FLUTTER_TARGET=lib/main.dart"
|
||||
|
||||
@@ -6,7 +6,7 @@ import 'package:flutter/material.dart';
|
||||
final jobWithExternalData = QueryJob<String, double>(
|
||||
queryKey: "query-external-data",
|
||||
cacheTime: const Duration(seconds: 10),
|
||||
refetchOnExternalDataChange: false,
|
||||
refetchOnExternalDataChange: true,
|
||||
task: (queryKey, data) {
|
||||
return Future.delayed(const Duration(milliseconds: 500),
|
||||
() => "Hello from $queryKey with $data");
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
# Generated code do not commit.
|
||||
file(TO_CMAKE_PATH "/opt/flutter" FLUTTER_ROOT)
|
||||
file(TO_CMAKE_PATH "/home/krtirtho/fvm/versions/3.3.5" FLUTTER_ROOT)
|
||||
file(TO_CMAKE_PATH "/home/krtirtho/dev/fl-query/packages/fl_query/example" PROJECT_DIR)
|
||||
|
||||
set(FLUTTER_VERSION "1.0.0+1" PARENT_SCOPE)
|
||||
@@ -10,7 +10,7 @@ set(FLUTTER_VERSION_BUILD 1 PARENT_SCOPE)
|
||||
|
||||
# Environment variables to pass to tool_backend.sh
|
||||
list(APPEND FLUTTER_TOOL_ENVIRONMENT
|
||||
"FLUTTER_ROOT=/opt/flutter"
|
||||
"FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5"
|
||||
"PROJECT_DIR=/home/krtirtho/dev/fl-query/packages/fl_query/example"
|
||||
"DART_DEFINES=RkxVVFRFUl9XRUJfQVVUT19ERVRFQ1Q9dHJ1ZQ=="
|
||||
"DART_OBFUSCATION=false"
|
||||
|
||||
Binary file not shown.
@@ -1,5 +1,5 @@
|
||||
// This is a generated file; do not edit or check into version control.
|
||||
FLUTTER_ROOT=/opt/flutter
|
||||
FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5
|
||||
FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example
|
||||
COCOAPODS_PARALLEL_CODE_SIGN=true
|
||||
FLUTTER_BUILD_DIR=build
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#!/bin/sh
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
export "FLUTTER_ROOT=/opt/flutter"
|
||||
export "FLUTTER_ROOT=/home/krtirtho/fvm/versions/3.3.5"
|
||||
export "FLUTTER_APPLICATION_PATH=/home/krtirtho/dev/fl-query/packages/fl_query/example"
|
||||
export "COCOAPODS_PARALLEL_CODE_SIGN=true"
|
||||
export "FLUTTER_BUILD_DIR=build"
|
||||
|
||||
@@ -58,18 +58,22 @@ class _InfiniteQueryBuilderState<T extends Object, Outside,
|
||||
|
||||
void init([T? previousData]) async {
|
||||
final bowl = QueryBowl.of(context);
|
||||
|
||||
final prevInfiniteQuery =
|
||||
bowl.getInfiniteQuery<T, Outside, PageParam>(widget.job.queryKey);
|
||||
infiniteQuery = bowl.addInfiniteQuery<T, Outside, PageParam>(
|
||||
widget.job,
|
||||
externalData: widget.externalData,
|
||||
key: uKey,
|
||||
);
|
||||
final hasExternalDataChanged = infiniteQuery!.externalData != null &&
|
||||
infiniteQuery!.prevUsedExternalData != null &&
|
||||
!isShallowEqual(
|
||||
infiniteQuery!.externalData!,
|
||||
infiniteQuery!.prevUsedExternalData!,
|
||||
);
|
||||
final hasExternalDataChanged = prevInfiniteQuery != null
|
||||
? !isShallowEqual(
|
||||
prevInfiniteQuery.externalData,
|
||||
prevInfiniteQuery.prevUsedExternalData,
|
||||
)
|
||||
: !isShallowEqual(
|
||||
infiniteQuery!.externalData,
|
||||
infiniteQuery!.prevUsedExternalData,
|
||||
);
|
||||
|
||||
if (infiniteQuery!.fetched && hasExternalDataChanged) {
|
||||
await infiniteQuery!.refetchPages();
|
||||
@@ -100,9 +104,7 @@ class _InfiniteQueryBuilderState<T extends Object, Outside,
|
||||
// } else {
|
||||
// init();
|
||||
// }
|
||||
} else if (oldWidget.externalData != null &&
|
||||
widget.externalData != null &&
|
||||
!isShallowEqual(oldWidget.externalData!, widget.externalData!)) {
|
||||
} else if (!isShallowEqual(oldWidget.externalData, widget.externalData)) {
|
||||
if (widget.job.refetchOnExternalDataChange ??
|
||||
queryBowl.refetchOnExternalDataChange) {
|
||||
QueryBowl.of(context).addInfiniteQuery(
|
||||
|
||||
@@ -383,12 +383,10 @@ class QueryBowl {
|
||||
if (prevQuery != null) {
|
||||
// run the query if its still not called or if externalData has
|
||||
// changed
|
||||
if (prevQuery.prevUsedExternalData != null &&
|
||||
externalData != null &&
|
||||
!isShallowEqual(
|
||||
prevQuery.prevUsedExternalData!,
|
||||
externalData,
|
||||
)) {
|
||||
if (!isShallowEqual(
|
||||
prevQuery.prevUsedExternalData,
|
||||
externalData,
|
||||
)) {
|
||||
prevQuery.setExternalData(externalData);
|
||||
}
|
||||
prevQuery.mount(key);
|
||||
@@ -425,12 +423,10 @@ class QueryBowl {
|
||||
if (prevInfiniteQuery != null) {
|
||||
// run the query if its still not called or if externalData has
|
||||
// changed
|
||||
if (prevInfiniteQuery.prevUsedExternalData != null &&
|
||||
externalData != null &&
|
||||
!isShallowEqual(
|
||||
prevInfiniteQuery.prevUsedExternalData!,
|
||||
externalData,
|
||||
)) {
|
||||
if (!isShallowEqual(
|
||||
prevInfiniteQuery.prevUsedExternalData,
|
||||
externalData,
|
||||
)) {
|
||||
prevInfiniteQuery.setExternalData(externalData);
|
||||
}
|
||||
prevInfiniteQuery.mount(key);
|
||||
@@ -499,12 +495,10 @@ class QueryBowl {
|
||||
if (prevQuery != null) {
|
||||
// run the query if its still not called or if externalData has
|
||||
// changed
|
||||
final hasExternalDataChanged = prevQuery.prevUsedExternalData != null &&
|
||||
externalData != null &&
|
||||
!isShallowEqual(
|
||||
prevQuery.prevUsedExternalData!,
|
||||
externalData,
|
||||
);
|
||||
final hasExternalDataChanged = !isShallowEqual(
|
||||
prevQuery.prevUsedExternalData,
|
||||
externalData,
|
||||
);
|
||||
prevQuery.mount(key);
|
||||
if (onData != null) prevQuery.addDataListener(onData);
|
||||
if (onError != null) prevQuery.addErrorListener(onError);
|
||||
|
||||
@@ -58,6 +58,7 @@ class _QueryBuilderState<T extends Object, Outside>
|
||||
|
||||
void init([T? previousData]) async {
|
||||
final bowl = QueryBowl.of(context);
|
||||
final prevQuery = bowl.getQuery<T, Outside>(widget.job.queryKey);
|
||||
query = bowl.addQuery<T, Outside>(
|
||||
widget.job,
|
||||
externalData: widget.externalData,
|
||||
@@ -66,13 +67,15 @@ class _QueryBuilderState<T extends Object, Outside>
|
||||
onData: widget.onData,
|
||||
onError: widget.onError,
|
||||
);
|
||||
|
||||
final hasExternalDataChanged = query!.externalData != null &&
|
||||
query!.prevUsedExternalData != null &&
|
||||
!isShallowEqual(
|
||||
query!.externalData!,
|
||||
query!.prevUsedExternalData!,
|
||||
);
|
||||
final hasExternalDataChanged = prevQuery != null
|
||||
? !isShallowEqual(
|
||||
prevQuery.externalData,
|
||||
prevQuery.prevUsedExternalData,
|
||||
)
|
||||
: !isShallowEqual(
|
||||
query!.externalData,
|
||||
query!.prevUsedExternalData,
|
||||
);
|
||||
|
||||
if (query!.fetched && hasExternalDataChanged) {
|
||||
await query!.refetch();
|
||||
@@ -103,9 +106,7 @@ class _QueryBuilderState<T extends Object, Outside>
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
} else if (oldWidget.externalData != null &&
|
||||
widget.externalData != null &&
|
||||
!isShallowEqual(oldWidget.externalData!, widget.externalData!)) {
|
||||
} else if (!isShallowEqual(oldWidget.externalData, widget.externalData)) {
|
||||
if (widget.job.refetchOnExternalDataChange ??
|
||||
bowl.refetchOnExternalDataChange) {
|
||||
bowl.fetchQuery(
|
||||
|
||||
@@ -31,7 +31,10 @@ bool isShallowEqualMap(Map list1, Map list2) {
|
||||
});
|
||||
}
|
||||
|
||||
bool isShallowEqual(Object obj1, Object obj2) {
|
||||
bool isShallowEqual(dynamic obj1, dynamic obj2) {
|
||||
if (obj1 == null && obj2 == null) return true;
|
||||
if ((obj1 == null && obj2 != null) || (obj2 == null && obj1 != null))
|
||||
return false;
|
||||
if (obj1 is List && obj2 is List) {
|
||||
return isShallowEqualList(obj1, obj2);
|
||||
} else if (obj1 is Set && obj2 is Set) {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
connectivity_plus=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/
|
||||
connectivity_plus_web=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/
|
||||
connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","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-10-12 22:11:05.557834","version":"3.3.4"}
|
||||
{"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.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.6/","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.5/","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-12-14 11:46:01.321906","version":"3.3.8"}
|
||||
@@ -1,6 +1,6 @@
|
||||
# This is a generated file; do not edit or check into version control.
|
||||
connectivity_plus=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/
|
||||
connectivity_plus_web=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
connectivity_plus=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/
|
||||
connectivity_plus_linux=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/
|
||||
connectivity_plus_macos=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/
|
||||
connectivity_plus_web=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/
|
||||
connectivity_plus_windows=/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"info":"This is a generated file; do not edit or check into version control.","plugins":{"ios":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","native_build":true,"dependencies":[]}],"macos":[{"name":"connectivity_plus_macos","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_macos-1.2.4/","native_build":true,"dependencies":[]}],"linux":[{"name":"connectivity_plus_linux","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_linux-1.3.1/","native_build":false,"dependencies":[]}],"windows":[{"name":"connectivity_plus_windows","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_windows-1.2.2/","native_build":true,"dependencies":[]}],"web":[{"name":"connectivity_plus_web","path":"/opt/flutter/.pub-cache/hosted/pub.dartlang.org/connectivity_plus_web-1.2.5/","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-10-12 22:11:08.760671","version":"3.3.4"}
|
||||
{"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.9/","native_build":true,"dependencies":[]}],"android":[{"name":"connectivity_plus","path":"/home/krtirtho/.pub-cache/hosted/pub.dartlang.org/connectivity_plus-2.3.9/","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.5/","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-12-14 11:46:05.508816","version":"3.3.8"}
|
||||
@@ -42,6 +42,9 @@ InfiniteQuery<T, Outside, PageParam>
|
||||
final oldOnError = usePrevious(onError);
|
||||
|
||||
final init = useCallback(([T? previousData]) {
|
||||
final hasExternalDataChanged = !isShallowEqual(
|
||||
infiniteQuery.value.externalData,
|
||||
infiniteQuery.value.prevUsedExternalData);
|
||||
infiniteQuery.value = queryBowl.addInfiniteQuery<T, Outside, PageParam>(
|
||||
job,
|
||||
externalData: externalData,
|
||||
@@ -50,10 +53,6 @@ InfiniteQuery<T, Outside, PageParam>
|
||||
onError: onError,
|
||||
);
|
||||
update();
|
||||
final hasExternalDataChanged = infiniteQuery.value.externalData != null &&
|
||||
infiniteQuery.value.prevUsedExternalData != null &&
|
||||
!isShallowEqual(infiniteQuery.value.externalData!,
|
||||
infiniteQuery.value.prevUsedExternalData!);
|
||||
if (infiniteQuery.value.fetched && hasExternalDataChanged) {
|
||||
infiniteQuery.value.refetchPages();
|
||||
} else if (!infiniteQuery.value.fetched) {
|
||||
@@ -95,42 +94,42 @@ InfiniteQuery<T, Outside, PageParam>
|
||||
}, []);
|
||||
|
||||
useEffect(() {
|
||||
final hasOnErrorChanged = oldOnError != onError && oldOnError != null;
|
||||
final hasOnDataChanged = oldOnData != onData && oldOnData != null;
|
||||
if (oldJob != null && oldJob.queryKey != job.queryKey) {
|
||||
disposeQuery();
|
||||
init();
|
||||
} else if (oldExternalData != null &&
|
||||
externalData != null &&
|
||||
!isShallowEqual(oldExternalData, externalData)) {
|
||||
if (job.refetchOnExternalDataChange ??
|
||||
queryBowl.refetchOnExternalDataChange) {
|
||||
QueryBowl.of(context).addInfiniteQuery(
|
||||
job,
|
||||
externalData: externalData,
|
||||
key: uKey,
|
||||
onData: onData,
|
||||
onError: onError,
|
||||
)..refetchPages();
|
||||
} else {
|
||||
QueryBowl.of(context)
|
||||
.getQuery(job.queryKey)
|
||||
?.setExternalData(externalData);
|
||||
}
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final hasOnErrorChanged = oldOnError != onError && oldOnError != null;
|
||||
final hasOnDataChanged = oldOnData != onData && oldOnData != null;
|
||||
if (oldJob != null && oldJob.queryKey != job.queryKey) {
|
||||
disposeQuery();
|
||||
init();
|
||||
} else if (!isShallowEqual(oldExternalData, externalData)) {
|
||||
if (job.refetchOnExternalDataChange ??
|
||||
queryBowl.refetchOnExternalDataChange) {
|
||||
QueryBowl.of(context).addInfiniteQuery(
|
||||
job,
|
||||
externalData: externalData,
|
||||
key: uKey,
|
||||
onData: onData,
|
||||
onError: onError,
|
||||
)..refetchPages();
|
||||
} else {
|
||||
QueryBowl.of(context)
|
||||
.getQuery(job.queryKey)
|
||||
?.setExternalData(externalData);
|
||||
}
|
||||
|
||||
if (hasOnDataChanged) infiniteQuery.value.removeDataListener(oldOnData);
|
||||
if (hasOnErrorChanged)
|
||||
infiniteQuery.value.removeErrorListener(oldOnError);
|
||||
} else {
|
||||
if (hasOnDataChanged) {
|
||||
infiniteQuery.value.removeDataListener(oldOnData);
|
||||
if (onData != null) infiniteQuery.value.addDataListener(onData);
|
||||
if (hasOnDataChanged) infiniteQuery.value.removeDataListener(oldOnData);
|
||||
if (hasOnErrorChanged)
|
||||
infiniteQuery.value.removeErrorListener(oldOnError);
|
||||
} else {
|
||||
if (hasOnDataChanged) {
|
||||
infiniteQuery.value.removeDataListener(oldOnData);
|
||||
if (onData != null) infiniteQuery.value.addDataListener(onData);
|
||||
}
|
||||
if (hasOnErrorChanged) {
|
||||
infiniteQuery.value.removeErrorListener(oldOnError);
|
||||
if (onError != null) infiniteQuery.value.addErrorListener(onError);
|
||||
}
|
||||
}
|
||||
if (hasOnErrorChanged) {
|
||||
infiniteQuery.value.removeErrorListener(oldOnError);
|
||||
if (onError != null) infiniteQuery.value.addErrorListener(onError);
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
@@ -75,23 +75,25 @@ Mutation<T, V> useMutation<T extends Object, V>({
|
||||
}, []);
|
||||
|
||||
useEffect(() {
|
||||
if (oldJob != null && oldJob.mutationKey != job.mutationKey) {
|
||||
disposeMutation();
|
||||
init();
|
||||
} else {
|
||||
if (oldOnData != onData && oldOnData != null) {
|
||||
mutation.value.removeDataListener(oldOnData);
|
||||
if (onData != null) mutation.value.addDataListener(onData);
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
if (oldJob != null && oldJob.mutationKey != job.mutationKey) {
|
||||
disposeMutation();
|
||||
init();
|
||||
} else {
|
||||
if (oldOnData != onData && oldOnData != null) {
|
||||
mutation.value.removeDataListener(oldOnData);
|
||||
if (onData != null) mutation.value.addDataListener(onData);
|
||||
}
|
||||
if (oldOnError != onError && oldOnError != null) {
|
||||
mutation.value.removeErrorListener(oldOnError);
|
||||
if (onError != null) mutation.value.addErrorListener(onError);
|
||||
}
|
||||
if (oldOnMutate != onMutate && oldOnMutate != null) {
|
||||
mutation.value.removeMutateListener(oldOnMutate);
|
||||
if (onMutate != null) mutation.value.addMutateListener(onMutate);
|
||||
}
|
||||
}
|
||||
if (oldOnError != onError && oldOnError != null) {
|
||||
mutation.value.removeErrorListener(oldOnError);
|
||||
if (onError != null) mutation.value.addErrorListener(onError);
|
||||
}
|
||||
if (oldOnMutate != onMutate && oldOnMutate != null) {
|
||||
mutation.value.removeMutateListener(oldOnMutate);
|
||||
if (onMutate != null) mutation.value.addMutateListener(onMutate);
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
@@ -41,6 +41,10 @@ Query<T, Outside> useQuery<T extends Object, Outside>({
|
||||
final oldOnError = usePrevious(onError);
|
||||
|
||||
final init = useCallback(([T? previousData]) {
|
||||
final hasExternalDataChanged = !isShallowEqual(
|
||||
query.value.externalData,
|
||||
query.value.prevUsedExternalData,
|
||||
);
|
||||
query.value = queryBowl.addQuery<T, Outside>(
|
||||
job,
|
||||
externalData: externalData,
|
||||
@@ -50,10 +54,6 @@ Query<T, Outside> useQuery<T extends Object, Outside>({
|
||||
onError: onError,
|
||||
);
|
||||
update();
|
||||
final hasExternalDataChanged = query.value.externalData != null &&
|
||||
query.value.prevUsedExternalData != null &&
|
||||
!isShallowEqual(
|
||||
query.value.externalData!, query.value.prevUsedExternalData!);
|
||||
if (query.value.fetched && hasExternalDataChanged) {
|
||||
query.value.refetch();
|
||||
} else if (!query.value.fetched) {
|
||||
@@ -82,51 +82,51 @@ Query<T, Outside> useQuery<T extends Object, Outside>({
|
||||
}, []);
|
||||
|
||||
useEffect(() {
|
||||
final hasOnErrorChanged = oldOnError != onError && oldOnError != null;
|
||||
final hasOnDataChanged = oldOnData != onData && oldOnData != null;
|
||||
if (oldJob != null && oldJob.queryKey != job.queryKey) {
|
||||
disposeQuery();
|
||||
WidgetsBinding.instance.addPostFrameCallback((_) {
|
||||
final hasOnErrorChanged = oldOnError != onError && oldOnError != null;
|
||||
final hasOnDataChanged = oldOnData != onData && oldOnData != null;
|
||||
if (oldJob != null && oldJob.queryKey != job.queryKey) {
|
||||
disposeQuery();
|
||||
|
||||
/// setting the new query's initial data as prev query's data
|
||||
/// when [job.keepPreviousData] is true and both are dynamic
|
||||
if (oldJob.isDynamic &&
|
||||
job.isDynamic &&
|
||||
oldJob.keepPreviousData == true &&
|
||||
job.keepPreviousData == true) {
|
||||
init(query.value.data);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
} else if (oldExternalData != null &&
|
||||
externalData != null &&
|
||||
!isShallowEqual(oldExternalData, externalData)) {
|
||||
if (job.refetchOnExternalDataChange ??
|
||||
queryBowl.refetchOnExternalDataChange) {
|
||||
QueryBowl.of(context).fetchQuery(
|
||||
job,
|
||||
externalData: externalData,
|
||||
onData: onData,
|
||||
onError: onError,
|
||||
key: uKey,
|
||||
);
|
||||
} else {
|
||||
QueryBowl.of(context)
|
||||
.getQuery(job.queryKey)
|
||||
?.setExternalData(externalData);
|
||||
}
|
||||
/// setting the new query's initial data as prev query's data
|
||||
/// when [job.keepPreviousData] is true and both are dynamic
|
||||
if (oldJob.isDynamic &&
|
||||
job.isDynamic &&
|
||||
oldJob.keepPreviousData == true &&
|
||||
job.keepPreviousData == true) {
|
||||
init(query.value.data);
|
||||
} else {
|
||||
init();
|
||||
}
|
||||
} else if (!isShallowEqual(oldExternalData, externalData)) {
|
||||
if (job.refetchOnExternalDataChange ??
|
||||
queryBowl.refetchOnExternalDataChange) {
|
||||
QueryBowl.of(context).fetchQuery(
|
||||
job,
|
||||
externalData: externalData,
|
||||
onData: onData,
|
||||
onError: onError,
|
||||
key: uKey,
|
||||
);
|
||||
} else {
|
||||
QueryBowl.of(context)
|
||||
.getQuery(job.queryKey)
|
||||
?.setExternalData(externalData);
|
||||
}
|
||||
|
||||
if (hasOnDataChanged) query.value.removeDataListener(oldOnData);
|
||||
if (hasOnErrorChanged) query.value.removeErrorListener(oldOnError);
|
||||
} else {
|
||||
if (hasOnDataChanged) {
|
||||
query.value.removeDataListener(oldOnData);
|
||||
if (onData != null) query.value.addDataListener(onData);
|
||||
if (hasOnDataChanged) query.value.removeDataListener(oldOnData);
|
||||
if (hasOnErrorChanged) query.value.removeErrorListener(oldOnError);
|
||||
} else {
|
||||
if (hasOnDataChanged) {
|
||||
query.value.removeDataListener(oldOnData);
|
||||
if (onData != null) query.value.addDataListener(onData);
|
||||
}
|
||||
if (hasOnErrorChanged) {
|
||||
query.value.removeErrorListener(oldOnError);
|
||||
if (onError != null) query.value.addErrorListener(onError);
|
||||
}
|
||||
}
|
||||
if (hasOnErrorChanged) {
|
||||
query.value.removeErrorListener(oldOnError);
|
||||
if (onError != null) query.value.addErrorListener(onError);
|
||||
}
|
||||
}
|
||||
});
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
import 'package:fl_query/fl_query.dart';
|
||||
import 'package:flutter_hooks/flutter_hooks.dart';
|
||||
|
||||
/// Simple hook based shorthand for [QueryBowl.of(context)]
|
||||
QueryBowl useQueryBowl() {
|
||||
final context = useContext();
|
||||
|
||||
return QueryBowl.of(context);
|
||||
}
|
||||
@@ -16,7 +16,8 @@ dependencies:
|
||||
sdk: flutter
|
||||
flutter_hooks: ^0.18.5+1
|
||||
uuid: ^3.0.6
|
||||
fl_query: ^0.3.1
|
||||
fl_query:
|
||||
path: ../fl_query
|
||||
|
||||
dev_dependencies:
|
||||
flutter_test:
|
||||
|
||||
Reference in New Issue
Block a user