Browse Source

dynamite,nextcloud,neon: Suffix serialize and deserialize functions

pull/168/head
jld3103 2 years ago
parent
commit
f24f9e838b
No known key found for this signature in database
GPG Key ID: 9062417B9E8EB7B3
  1. 4
      packages/dynamite/lib/src/openapi_builder.dart
  2. 6
      packages/neon/lib/src/utils/request_manager.dart
  3. 4
      packages/nextcloud/lib/src/nextcloud.openapi.dart

4
packages/dynamite/lib/src/openapi_builder.dart

@ -865,9 +865,9 @@ class OpenAPIBuilder implements Builder {
], ],
'};', '};',
'', '',
'T deserialize<T>(final dynamic data) => _deserializers[T]!(data) as T;', 'T deserialize$prefix<T>(final dynamic data) => _deserializers[T]!(data) as T;',
'', '',
'dynamic serialize<T>(final T data) => _serializers[T]!(data);', 'dynamic serialize$prefix<T>(final T data) => _serializers[T]!(data);',
'// coverage:ignore-end', '// coverage:ignore-end',
]); ]);
} }

6
packages/neon/lib/src/utils/request_manager.dart

@ -34,7 +34,7 @@ class RequestManager {
try { try {
subject.add( subject.add(
Result( Result(
unwrap(deserialize<R>(json.decode((await cache!.get(key))!))), unwrap(deserializeNextcloud<R>(json.decode((await cache!.get(key))!))),
null, null,
loading: true, loading: true,
cached: true, cached: true,
@ -48,7 +48,7 @@ class RequestManager {
try { try {
final response = await (disableTimeout ? call() : timeout(call)); final response = await (disableTimeout ? call() : timeout(call));
await cache?.set(key, json.encode(serialize<R>(response))); await cache?.set(key, json.encode(serializeNextcloud<R>(response)));
subject.add(Result.success(unwrap(response))); subject.add(Result.success(unwrap(response)));
} catch (e, s) { } catch (e, s) {
debugPrint(e.toString()); debugPrint(e.toString());
@ -57,7 +57,7 @@ class RequestManager {
try { try {
subject.add( subject.add(
Result( Result(
unwrap(deserialize<R>(json.decode((await cache!.get(key))!))), unwrap(deserializeNextcloud<R>(json.decode((await cache!.get(key))!))),
null, null,
loading: false, loading: false,
cached: true, cached: true,

4
packages/nextcloud/lib/src/nextcloud.openapi.dart

@ -6041,7 +6041,7 @@ final _serializers = <Type, dynamic Function(dynamic)>{
data.map((final e) => e.toJson()).toList(), data.map((final e) => e.toJson()).toList(),
}; };
T deserialize<T>(final dynamic data) => _deserializers[T]!(data) as T; T deserializeNextcloud<T>(final dynamic data) => _deserializers[T]!(data) as T;
dynamic serialize<T>(final T data) => _serializers[T]!(data); dynamic serializeNextcloud<T>(final T data) => _serializers[T]!(data);
// coverage:ignore-end // coverage:ignore-end

Loading…
Cancel
Save