mirror of
https://github.com/lucavenir/go_router_riverpod.git
synced 2025-08-06 14:59:53 +08:00
13 lines
271 B
Dart
13 lines
271 B
Dart
import 'dart:async';
|
|
|
|
import 'package:hooks_riverpod/hooks_riverpod.dart';
|
|
|
|
extension CacheFor<T> on AutoDisposeRef<T> {
|
|
void cacheFor(Duration duration) {
|
|
final link = keepAlive();
|
|
final timer = Timer(duration, link.close);
|
|
|
|
onDispose(timer.cancel);
|
|
}
|
|
}
|