more tests added for Query
prefetchQuery support added seperate methods for adding & removing listeners for events of both query & mutations refetchInterval not working when used Query.fromOptions bug fixed
This commit is contained in:
@@ -56,12 +56,14 @@ class _BasicMutationExampleState extends State<BasicMutationExample> {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"# Basic Mutation Example",
|
||||
"# Basic Mutation Example (with Failure & Retry simulation)",
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
MutationBuilder<Map, Map<String, dynamic>>(
|
||||
job: basicMutationJob,
|
||||
onMutate: (v) {
|
||||
final data =
|
||||
QueryBowl.of(context).getQuery(successJob.queryKey)?.data;
|
||||
QueryBowl.of(context)
|
||||
.setQueryData<String, void>(successJob.queryKey, (oldData) {
|
||||
if (oldData?.contains("After Mutate (OPTIMISTIC UPDATE)") ==
|
||||
@@ -70,6 +72,11 @@ class _BasicMutationExampleState extends State<BasicMutationExample> {
|
||||
}
|
||||
return "$oldData - After Mutate (OPTIMISTIC UPDATE)";
|
||||
});
|
||||
return data;
|
||||
},
|
||||
onData: (data, variables, context) {
|
||||
print("Passed Variable: $variables");
|
||||
print("Safe Previous Value: $context");
|
||||
},
|
||||
builder: (context, mutation) {
|
||||
return Padding(
|
||||
@@ -94,7 +101,7 @@ class _BasicMutationExampleState extends State<BasicMutationExample> {
|
||||
"title": title,
|
||||
"body": body,
|
||||
"id": id,
|
||||
}, onData: (data) {
|
||||
}, onData: (data, variables, context) {
|
||||
// resetting the form
|
||||
titleController.text = "";
|
||||
bodyController.text = "";
|
||||
|
||||
@@ -49,7 +49,7 @@ class BasicHookMutationExample extends HookWidget {
|
||||
crossAxisAlignment: CrossAxisAlignment.start,
|
||||
children: [
|
||||
Text(
|
||||
"# Basic Mutation Hook Example",
|
||||
"# Basic Mutation Hook Example (with failure & retry simulation)",
|
||||
style: Theme.of(context).textTheme.headline5,
|
||||
),
|
||||
Padding(
|
||||
@@ -74,7 +74,7 @@ class BasicHookMutationExample extends HookWidget {
|
||||
"title": title,
|
||||
"body": body,
|
||||
"id": id,
|
||||
}, onData: (data) {
|
||||
}, onData: (data, variable, context) {
|
||||
// resetting the form
|
||||
titleController.text = "";
|
||||
bodyController.text = "";
|
||||
|
||||
Reference in New Issue
Block a user