docs: update according to the new query bowl refactor
This commit is contained in:
@@ -3,9 +3,11 @@ title: QueryBowl Scope
|
||||
sidebar_position: 1
|
||||
---
|
||||
|
||||
The first thing needed for storing any form of data is a store. QueryBowlScope is basically a `StatefulWidget` which wraps around the actual store `QueryBowl`. It is similar to `ProviderScope` in riverpod & `MultiProvider` provider. But it can be used only once at the very top level of the application
|
||||
The first thing needed for storing any form of data is a store. QueryBowlScope is basically a `InheritedWidget` which wraps around the actual store `QueryBowl`. It is similar to `ProviderScope` in riverpod & `MultiProvider` provider. It just inject the instance of `QueryBowl` to the `BuildContext`
|
||||
|
||||
You must use wrap your `MaterialApp` or `CupertinoApp` or `FluentApp` or `MacosApp` with `QueryBowlScope`
|
||||
You must use wrap your `MaterialApp` or `CupertinoApp` or `FluentApp` or `MacosApp` with `QueryBowlScope` for using same `QueryBowl` across all screens/routes
|
||||
|
||||
Or, if you want you can use `QueryBowlScope` anywhere in the Widget Tree to provide the `QueryBowl` instance to the children.
|
||||
|
||||
```dart
|
||||
class MyApp extends StatelessWidget {
|
||||
@@ -14,6 +16,7 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return QueryBowlScope(
|
||||
bowl: QueryBowl(),
|
||||
child: MaterialApp(
|
||||
title: 'Fl-Query Example',
|
||||
home: const MyHomePage(),
|
||||
@@ -24,7 +27,7 @@ class MyApp extends StatelessWidget {
|
||||
|
||||
```
|
||||
|
||||
`QueryBowlScope` has many properties that can be configured. You can configure refetch behaviors, thresholds, delays etc along with cache time
|
||||
`QueryBowl` has many properties that can be configured. You can configure refetch behaviors, thresholds, delays etc along with cache time
|
||||
|
||||
Here I'm increasing the staleTime to 10 seconds. This means that if the data is outdated after 10 seconds & will be refetched in the background smartly when needed. The default value is 1 seconds
|
||||
|
||||
@@ -35,7 +38,9 @@ class MyApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return QueryBowlScope(
|
||||
staleTime: Duration(seconds: 10),
|
||||
bowl: QueryBowl(
|
||||
staleTime: Duration(seconds: 10),
|
||||
),
|
||||
child: MaterialApp(
|
||||
title: 'Fl-Query Example',
|
||||
home: const MyHomePage(),
|
||||
|
||||
@@ -39,6 +39,7 @@ class MyApp extends StatelessWidget {
|
||||
// QueryBowlScope creates a Bowl (metaphor for Collection/Store)
|
||||
// for all the Queries & Mutations
|
||||
return QueryBowlScope(
|
||||
bowl: QueryBowl(),
|
||||
child: MaterialApp(
|
||||
title: 'Fl-Query Quick Start',
|
||||
theme: ThemeData(
|
||||
|
||||
Reference in New Issue
Block a user