hydrate static method
void
hydrate(})
Restores cache records from a dehydratedState Map into the current scope.
Reconstitutes QueryCacheEntry instances with their original timestamps, stale times, cache times, and stale flags. Freshly hydrated entries are immediately recognized as fresh by BloomQuery and BloomInfiniteQuery, starting in QueryStatus.success with data present and avoiding redundant SSR double-fetches.
Supply deserialize to convert raw JSON values back into domain models.
BloomData.hydrate(
dehydratedMap,
deserialize: (rawJson, key) {
if (key.first == 'todos') {
return (rawJson as List).map((e) => Todo.fromJson(e as Map<String, dynamic>)).toList();
}
return rawJson;
},
);
See also:
- dehydrate, to capture the cache into a serializable structure.
- hydrateFromJson, for direct hydration from a raw JSON string.
Implementation
static void hydrate(
Map<String, dynamic> dehydratedState, {
dynamic Function(dynamic json, List<dynamic> key)? deserialize,
}) =>
currentScope.hydrate(dehydratedState, deserialize: deserialize);