brick_offline_first 3.3.0 brick_offline_first: ^3.3.0 copied to clipboard
A Brick domain that routes data fetching through local providers before remote providers.
Unreleased #
3.3.0 #
- Added
subscriptionByQuery
toOfflineFirstRepository#notifySubscriptionsWithLocalData
to pass a custom map ofStreamControllers
- Add
GetFirstMixin
for convenient retrieval of the first results ofOfflineFirstRepository#get
- Close all controllers in
OfflineFirstRepository#subscriptions
and clear the map onOfflineFirstRepository#reset
3.2.1 #
- Add
OfflineFirstSerdes#toSupabase
abstract method
3.2.0 #
- Apply desired policy to all association fetches during
OfflineFirstRepository#get
requests. Fixes #371. - Upgrade minimum Dart to 2.18
3.1.0 #
- Apply standardized lints
- Respect
awaitRemote
policy forOfflineFirstRepository#get
- fixes a bug where an instance in memory cache would early-return before hitting remote despite the requestedawait
oralwaysHydrate
policy
3.0.3 #
- Support Dart 3
3.0.2 #
- Permit awaiting remote on first
get
inOfflineFirstRepository#subscribe
. While the default for thepolicy
argument of this method has changed, it was unapplied (.localOnly
was used regardless).
3.0.1 #
- Resolve concurrent modification error when looping through subscriptions
3.0.0 #
- Remove
brick_sqlite_abstract
- Remove
brick_offline_first_abstract
- Add
OfflineFirstRepository#subscribe
. The query provided when invoked is stored on the repository. Whenever data is locally mutated withstoreRemoteResults
orupsert
ordelete
that matches one of these stored queries, the stream receives the latest data for the query. It is strongly recommended to store the subscription after creating the stream and listening to it; cancelling the stream will close it and remove the stream to prevent memory leaks. - Add
fieldsToOfflineFirstRuntimeDefinition
toOfflineFirstAdapter
. This exposes@OfflineFirst(where
configuration to repositories - Add
applyToRemoteDeserialization
to@OfflineFirst
. Whentrue
(the default and existing behavior), deserializing methods will query based onwhere
configuration
2.1.2 #
- Set default of 5 seconds for
RequestSqliteCacheManager#processingInterval
2.1.1 #
- Include type argument on
_upsertLocal
within#upsert
2.1.0 #
- Loosen dependency restrictions to major versions
- Remove Flutter dependency by upgrading
brick_sqlite
2.0.0 #
- BREAKING CHANGE
requireRemote
has been removed fromget()
andgetBatched()
. Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate
- BREAKING CHANGE
hydrateUnexisting
has been removed fromget()
. Instead, usepolicy: OfflineFirstGetPolicy.awaitRemoteWhenNoneExist
(this is the default). - BREAKING CHANGE
alwaysHydrate
has been removed fromget()
. Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate
. - BREAKING CHANGE This package no longer includes the
OfflineFirstWithRest
domain. Please addbrick_offline_first_with_rest: any
to yourpubspec.yaml
and update package imports appropriately. - Use forked
brick_offline_first_with_PROVIDER_abstract
packages - BREAKING CHANGE
rest
properties have been removed fromOfflineFirstException
. UseOfflineFirstWithRestException
instead frombrick_offline_first_with_rest
. - Add
GraphqlOfflineRequestQueue
to support offline caching within theGraphqlProvider
- Add
applyPolicyToQuery
toOfflineFirstRepository
to add the policy before requests are made to remote providers. - Add
OfflineFirstDeletePolicy
,OfflineFirstGetPolicy
, andOfflineFirstUpsertPolicy
to override default behavior delete
now supports requiring a successful remote withOfflineFirstDeletePolicy.requireRemote
. If the app is offline, normally handled exceptions (ClientException
andSocketException
) arerethrow
n. (#182)upsert
now supports requiring a successful remote withOfflineFirstUpsertPolicy.requireRemote
. If the app is offline, normally handled exceptions (ClientException
andSocketException
) arerethrow
n.- Rename
RequestSqliteCacheManager
toRestRequestSqliteCacheManager
- Rename
OfflineQueueHttpClient
toRestOfflineQueueClient
- Rename
OfflineRequestQueue
toRestOfflineRequestQueue
2.0.0-rc.4 #
- Add
applyPolicyToQuery
toOfflineFirstRepository
to add the policy before requests are made to remote providers.
2.0.0-rc.3 #
- Add
OfflineFirstDeletePolicy
,OfflineFirstGetPolicy
, andOfflineFirstUpsertPolicy
to override default behavior delete
now supports requiring a successful remote withOfflineFirstDeletePolicy.requireRemote
. If the app is offline, normally handled exceptions (ClientException
andSocketException
) arerethrow
n. (#182)upsert
now supports requiring a successful remote withOfflineFirstUpsertPolicy.requireRemote
. If the app is offline, normally handled exceptions (ClientException
andSocketException
) arerethrow
n.- BREAKING CHANGE
requireRemote
has been removed fromget()
andgetBatched()
. Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate
- BREAKING CHANGE
hydrateUnexisting
has been removed fromget()
. Instead, usepolicy: OfflineFirstGetPolicy.awaitRemoteWhenNoneExist
(this is the default). - BREAKING CHANGE
alwaysHydrate
has been removed fromget()
. Instead, usepolicy: OfflineFirstGetPolicy.alwaysHydrate
.
2.0.0-rc.2 #
- BREAKING CHANGE This package no longer includes the
OfflineFirstWithRest
domain. Please addbrick_offline_first_with_rest: any
to yourpubspec.yaml
and update package imports appropriately. - Use forked
brick_offline_first_with_PROVIDER_abstract
packages - BREAKING CHANGE
rest
properties have been removed fromOfflineFirstException
. UseOfflineFirstWithRestException
instead frombrick_offline_first_with_rest
.
2.0.0-rc.1 #
- Add
GraphqlOfflineRequestQueue
to support offline caching within theGraphqlProvider
- Rename
RequestSqliteCacheManager
toRestRequestSqliteCacheManager
- Rename
OfflineQueueHttpClient
toRestOfflineQueueClient
- Rename
OfflineRequestQueue
toRestOfflineRequestQueue
1.1.0 #
- Carry
providerArgs
from query when usinggetBatched
(#200) - Add Flutter Lints
1.0.0 #
- Null safety
- Priority for the next job to process from the queue - when processing requests in serial - has changed from
'$HTTP_JOBS_CREATED_AT_COLUMN ASC, $HTTP_JOBS_ATTEMPTS_COLUMN DESC, $HTTP_JOBS_UPDATED_AT ASC'
to'$HTTP_JOBS_CREATED_AT_COLUMN ASC'
; this uses the job column introduced in 0.0.7 (26 May 2020) and will not affect any implementations using 0.0.7 or higher. RequestSqliteCache
no longer queries cached requests based on headers; requests are rediscovered based on their encoding, URL, request method, and body. Rehydrated (reattempted) requests will be hydrated with headers from the original request.- BREAKING CHANGE Field types in models
Set<Future<OfflineFirstModel>>
,List<Future<OfflineFirstModel>>
, andFuture<OfflineFirstModel>
are no longer supported. Instead, useSet<OfflineFirstModel>
,List<OfflineFirstModel>
, andOfflineFirstModel
(the adapters willawait
each). - BREAKING CHANGE
StubOfflineFirstWithRest
is functionally changed. SQLiteFFI has satisfied much of the original stubbing required for this class, and http's testing.dart library is sufficient to not require Mockito. Therefore,verify
calls will no longer be effective in testing on the client. Instead, passStubOfflineFirstWithRest.client
to yourRestProvider#client
with the response values.StubOfflineFirstWithRestModel
has been removed. Please review Offline First Testing for implementation examples. - Do not reprocess queue requests during a single attempt. Server response times may be greater than the reattempt timer; in these situations, requests should remain locked.
- Introduce mutex around processing in the
OfflineRequestQueue
. This will avoid simultaneous DB writes on different isolates* while a previous operation is still performing.
*Or sub routines? Microtasks? It's unclear how Timer moves its work to the background or how to force it to remain in the original "thread."
0.1.2 #
- Add
mixins.dart
for non essential but still regularly requested features that depend on a specific format of remote data or are useful variations of existing features.DeleteAllMixin
andDestructiveLocalSyncFromRemoteMixin
are the first two such mixins. - Expose
RequestSqliteCache#findRequestInDatabase
for subclass methods. (#111)
0.1.1 #
- Gracefully handle
SocketException
errors when the application is offline - Call
exists
inOfflineFirstRepository#get
after the memory provider has already been queried. This method can query the SqliteProvider which is an unnecessary database call when the model exists in the memory provider. - RequestSqliteCacheManager: access SQLite db safely to avoid race conditions
- RequestSqliteCacheManager: refactor database path. This does not change the database's existing path as the use of
getDatabasesPath()
in the implementation was duplicating default functionality
0.1.0 #
- BREAKING CHANGE One-to-many and many-to-many SQLite associations are no longer stored as JSON-encoded strings (i.e.
[1, 2, 3]
in a varchar column). Join tables are now generated by Brick. To convert existing data, please refer to the brick_sqlite CHANGELOG notes. If you do not care about existing migration and have not widely distributed your app, simply delete all existing migrations, delete all existing app installs, and runflutter pub run build_runner build
in your project root. - Fixes undefined method when calling
hydrate
offline. The remote provider would return null, and SQLite/memory cache would not adequately store results. Instead, when a null response is returned from the remote provider, subsequent provider updates are skipped. - Adds a configurable option to throw on status codes that are normally swallowed in
OfflineFirstWithRest#upsert
(such as 404, 50x).
0.0.7 #
- Add
reattemptForStatusCode
forOfflineFirstWithRestRepository#upsert
requests. When the response matches a reattempt code, an exception is not thrown and the instance is returned instead. - Add
501
toOfflineQueueHttpClient#reattemptForStatusCode
defaults - Insert a
created_at
column for the OfflineRequestQueue. - Fix a bug where an HTTP request would be immediately duplicated. In some race conditions, the interval timer would immediately recreate the request after it was inserted and before the HTTP response was received.
- Bump sqflite to 1.3.0
- BREAKING CHANGE Remove StubSqlite from StubOfflineFirst. SQLite should be migrated by the repository and data upserted as it would be within the app.
StubOfflineFirst
is now only concerned with REST responses. - BREAKING CHANGE Remove interval from
OfflineRequestQueue
in favor of declaring it once onRequestSqliteCacheManager
. To migrate, pass a customRequestSqliteCacheManager
with the interval time to theOfflineFirstWithRestRepository
constructor. - BREAKING CHANGE
StubOfflineFirstWithRest
must be invoked synchronously (in order to run migrations). When setting up stub in testing, callawait StubOfflineFirstWithRest(...).initialize()
or, in a cleaner syntax,final stub = StubOfflineFirstWithRest(...); await stub.initialize()
.initialize
will no longer be automatically invoked.
0.0.6 #
- Remove maximumRequests configuration for the OfflineFirstQueue. One request should be processed at a time in serial
- Optionally ignore Tunnel not found requests (these occur when connectivity exists but the queried endpoint is unreachable) when making repository requests
- Adds argument to repository to reattempt requests based on the status code from the response
OfflineRequestQueue#process
became a protected method- Added
RequestSqliteCacheManager
to interact with the queue. This new class receives most static methods fromRequestSqliteCache
. - Added
OfflineRequestQueue#requestManager
to access queue via aRequestSqliteCacheManager
instance. - Renamed
RequestSqliteCache.unprocessedRequests
toRequestSqliteCacheManager.prepareNextRequestToProcess
as the expected query only returns one locked row at a time. RequestSqliteCacheManager.prepareNextRequestToProcess
locks all unprocessed rows, not just the first one- Add ability to toggle
serialProcessing
forOfflineRequestQueue
- Private member
OfflineFirstWithRestRepository#offlineRequestQueue
is now protected - Remove
isConnected
member fromOfflineFirstRepository
and associated Connectivity code. The connection should not matter to the subclass as it, or a supporting class, should track outbound requests.
0.0.5+1 #
- Bump dependencies
0.0.5 #
- Rename
Query#params
toQuery#providerArgs
, reflecting the much narrower purpose of the member
0.0.2 #
- Export REST annotations/classes from
OfflineFirstWithRestRepository
for convenient access - Don't require
MemoryCacheProvider
inOfflineFirstWithRestRepository
as it's not required forOfflineFirstRepository
- Fix linter hints