disposable_utils

Creator: coderz1093

Last updated:

0 purchases

disposable_utils Image
disposable_utils Images

Languages

Categories

Add to Cart

Description:

disposable utils

disposable #
Provides a one abstract mechanism for releasing resources and utils for Dart and Flutter #
Did you notice there is no one defined method to release object resources in Dart and Flutter?
StreamController.close(), StreamSubscription.cancel() and many dispose() methods
in different Flutter object does the same - they free held information. But they doesn't have
any one defined interface for it. Disposable does it.
DisposableCollector is a composite of many disposables, which can be disposed as one.
It also provides extension methods to make life easier for streams.
Do you recognize it?
class SomeDisposable {
/// ...

final _subscription = someStream.listen(
(value) => doSomethingWith(value)
);

/// ...

void dispose() {
_subscription.cancel();
}
}
copied to clipboard
With DisposableCollector it will look like :
class SomeDisposable extends DisposableCollector {
/// ...
someStream
.listen((value) => doSomethingWith(value))
.addTo(this);

/// ...
}
copied to clipboard
And you can make Disposable from any of your objects with factory
final disposable = Disposable.create(yourObject, () => yourObject.close());
// or
final disposable = yourObject.toDisposable(() => yourObjectClose());
copied to clipboard

License

For personal and professional use. You cannot resell or redistribute these repositories in their original state.

Files In This Product:

Customer Reviews

There are no reviews.