DeduplicationRepository<Info, DS extends DataSourceCallable<Info> > class
abstract
A SafeRepositoryDatasourceCallable enhanced with request deduplication logic.
This repository is ideal for preventing redundant network calls when multiple parts of the application request the same data at the same time.
How it works: If a call is already in progress for a specific set of Params, any subsequent calls with the same Params will wait for the first call's result instead of triggering a new request.
Example Scenario:
Imagine two different UI Widgets call getUser(id: '1') at the exact
same millisecond.
- The first call triggers the
DataSource. - The second call "hooks" into the first one.
- Both widgets receive the same
Userobject simultaneously when the network request finishes.
Inherits all safety features from SafeRepositoryDatasourceCallable.
- Inheritance
-
- Object
- Repository
- RepositoryDataSource<
DS> - RepositoryDataSourceCallable<
Info, DS> - SafeRepositoryDatasourceCallable<
Info, DS> - DeduplicationRepository
- Mixed-in types
-
- DeduplicationManagement<
Info, DS>
- DeduplicationManagement<
Constructors
- DeduplicationRepository({required DS dataSource})
-
Creates a DeduplicationRepository with the provided
dataSource.
Properties
- dataSource → DS
-
The DataSource instance used by this repository to fetch or persist data.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- observer → SafeCallableRepositoryObserver
-
no setterinherited
- onException → RepositoryError Function(Object exception, StackTrace stackTrace)
-
Default handler for unexpected exceptions (e.g., parsing errors).
Logs the error and returns OnExceptionRepositoryError.
no setterinherited
- onInadmissibleException → RepositoryError Function(InadmissibleDataSourceException exception, StackTrace stackTrace)
-
Default handler for inadmissible exceptions (e.g., 404 Not Found).
Logs the error and returns InadmissibleRepositoryError.
no setterinherited
- onUnControlException → RepositoryError Function(UnControlDataSourceException exception, StackTrace stackTrace)
-
Default handler for uncontrolled exceptions (e.g., 500 Internal Server Error).
Logs the error and returns UnControlRepositoryError.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
call(
{required covariant Params repositoryParams}) → Future< Either< RepositoryError, Info> > -
Overrides the repository call to apply deduplication.
inherited
-
dispose(
) → void -
Frees up resources and notifies the observer.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
safeCall(
{required FutureOr< Either< call()}) → FutureOr<RepositoryError, Info> >Either< RepositoryError, Info> > -
Executes a function safely, catching defined exceptions and mapping them to Left.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited