impulse 0.7.0
impulse: ^0.7.0 copied to clipboard
Minimalist state management and dependency injection.
import 'package:impulse/impulse.dart';
final counterRef = Ref((store) => Counter());
class Counter extends ImpulseNotifier {
int count = 0;
void increment() {
count += 1;
notify();
}
}
void main() async {
$store.watch(counterRef, (count) => print('Count is $count'));
$store.get(counterRef).increment();
$store.reset();
}
void main() async {
final result = await attempt(() => fetchData());
if (result is AsyncFailure) {
print('Fetch failed: ${result.error}');
return;
}
print('Fetched value: ${result.value}');
}