scoped_deps 0.2.1
scoped_deps: ^0.2.1 copied to clipboard
A simple Dart library for managing scoped dependencies built on top of Zones from dart:async.
import 'package:scoped_deps/scoped_deps.dart';
final valueProvider = create(() => 42);
int get value => read(valueProvider);
void main() {
runScoped(() {
print(value); // 42
runScoped(() {
print(value); // 0
}, values: {valueProvider.overrideWith(() => 0)});
print(value); // 42, restored after the nested scope exits
}, values: {valueProvider});
}