Internal API change
now query & mutation share same base class queries are now self-refetchable queryJobs & mutationJobs now support dynamic key allowing dynamic Query/Mutation creation query status & mutation status are now just on point & accurate
This commit is contained in:
@@ -1,17 +1,43 @@
|
||||
import 'package:fl_query/mutation.dart';
|
||||
|
||||
class MutationJob<T extends Object, V> {
|
||||
final String mutationKey;
|
||||
String _mutationKey;
|
||||
MutationTaskFunction<T, V> task;
|
||||
final int? retries;
|
||||
final Duration? retryDelay;
|
||||
final Duration? cacheTime;
|
||||
|
||||
MutationJob({
|
||||
required this.mutationKey,
|
||||
required String mutationKey,
|
||||
required this.task,
|
||||
this.retries,
|
||||
this.retryDelay,
|
||||
this.cacheTime,
|
||||
});
|
||||
}) : _mutationKey = mutationKey;
|
||||
|
||||
String get mutationKey => _mutationKey;
|
||||
|
||||
static MutationJob<T, V> Function(String queryKey)
|
||||
withVariableKey<T extends Object, V>({
|
||||
required MutationTaskFunction<T, V> task,
|
||||
|
||||
/// a extra key joined with mutationKey by a '#'
|
||||
///
|
||||
/// useful for matching a group mutation
|
||||
String? preMutationKey,
|
||||
int? retries,
|
||||
Duration? retryDelay,
|
||||
Duration? cacheTime,
|
||||
}) {
|
||||
return (String mutationKey) {
|
||||
if (preMutationKey != null) mutationKey = "$preMutationKey#$mutationKey";
|
||||
return MutationJob<T, V>(
|
||||
mutationKey: mutationKey,
|
||||
task: task,
|
||||
retries: retries,
|
||||
retryDelay: retryDelay,
|
||||
cacheTime: cacheTime,
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user