api and storage restructure
This commit is contained in:
@@ -1,27 +1,14 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import '../../../requestCache.dart';
|
||||
import 'getSubjects.dart';
|
||||
import 'getSubjectsResponse.dart';
|
||||
|
||||
class GetSubjectsCache extends RequestCache<GetSubjectsResponse> {
|
||||
GetSubjectsCache({
|
||||
void Function(GetSubjectsResponse)? onUpdate,
|
||||
void Function(Exception)? onError,
|
||||
bool? renew,
|
||||
}) : super(
|
||||
RequestCache.cacheHour,
|
||||
onUpdate,
|
||||
onError: onError ?? RequestCache.ignore,
|
||||
renew: renew,
|
||||
class GetSubjectsCache extends SimpleCache<GetSubjectsResponse> {
|
||||
GetSubjectsCache({super.onUpdate, super.onError, super.renew})
|
||||
: super(
|
||||
cacheTime: RequestCache.cacheHour,
|
||||
loader: () => GetSubjects().run(),
|
||||
fromJson: GetSubjectsResponse.fromJson,
|
||||
) {
|
||||
start('wu-subjects');
|
||||
}
|
||||
|
||||
@override
|
||||
Future<GetSubjectsResponse> onLoad() => GetSubjects().run();
|
||||
|
||||
@override
|
||||
onLocalData(String json) => GetSubjectsResponse.fromJson(jsonDecode(json));
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user