Riverpod Swiss knife
A collection of utilities and extensions for Riverpod.
Features
Here's what you can do with this package.
Caching strategies
cacheFor: cache the value for a specified durationaddDisposeDelay: delay the disposal of a provider by a specified duration
Ref utilities
debounceFor: debounce a provider for a specified durationtimeout: triggers a callback after a specified durationonRepeat: triggers a callback repeatedly, with the specified intervalrun: executes an async provider, keeping it alive until its futures completes
Invalidation strategies
invalidateSelfAfter: self-invalidates after a specified durationinvalidatePeriodically: invalidates a provider periodically at the specified interval
Provider Listenable utilities
asAsync: transforms any provider updates, by emittingAsyncValueinsteadwhere: filters state notifications from an async provider using an explicit(previous, next) → boolpredicate- notice how it's similar to
.selectAsync, except.wherekeeps the sameAsyncValue<T>type and suppresses notifications, rather than allowing mapping to a new type
- notice how it's similar to
Notifier utilities
update: update the state based on the previous state, similarly to AsyncNotifier'supdatemethod.
Usage
See the example folder for more details.
Important note
Please read the API docs carefully before using any of the above utilities.
Libraries
- riverpod_swiss_knife
- A Swiss Army knife for Riverpod.