dispose_scope 1.0.0
dispose_scope: ^1.0.0 copied to clipboard

Package reducing boiler related to disposing/canceling/closing objects.

DisposeScope #

DisposeScope reduces the amount of boilerplate related to disposing/canceling/closing objects when no longer needed. The DisposeScope class stores references to appropriate dispose/close/cancel methods and calls them when the scope is disposed.

This package can be used by itself however it's mainly intended as base for flutter_dispose_scope and bloc_dispose_scope packages.

Usage #

import 'package:dispose_scope/dispose_scope.dart';

final disposeScope = DisposeScope();

// StreamSubscription will be cancelled when disposeScope is disposed
const Stream.empty().listen((event) {}).disposed(disposeScope);

// Timer will be cancelled when disposeScope is disposed
Timer(Duration.zero, () {}).disposed(disposeScope);

disposeScope.dispose();

Supported types #

This package contains extension methods for dart standard library classes requiring clean up. For additional extension methods checkout flutter_dispose_scope and bloc_dispose_scope.

0
likes
110
pub points
29%
popularity

Publisher

odrowaz.dev

Package reducing boiler related to disposing/canceling/closing objects.

Homepage
Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

More

Packages that depend on dispose_scope