disposable 0.1.0 copy "disposable: ^0.1.0" to clipboard
disposable: ^0.1.0 copied to clipboard

outdatedDart 1 only

An implementation of disposable for Dart.

An implementation of disposable for Dart.

Build Status

Introduction #


Software should be like Kleenex, strong and disposable!


This library originated as a mechinism for cleaning up resources when you're done with them.

Features #

  • IDisposable - interface
  • Disposable - class
  • CompositeDisposable - class
  • using - global function
  • usingAsync - global function

Getting Started #

1. Add the following to your project's pubspec.yaml and run pub install.

dependencies:
  disposable: any

2. Add the correct import for your project.

import 'package:disposable/disposable.dart';

3. Start using.

Naive/pointless example:

var recPort = new ReceivePort();
var disposable = new Disposable(() => recPort.close());
... do stuff with recPort
disposable.dispose();

Better example:

var recPort = new ReceivePort();
using(new Disposable(() => recPort.close()), (disposable) {
	... do stuff with recPort
});

And if you have something that actually implements IDisposable:

using(new MyThing(), (myThing) {
	... do stuff with myThing
});

Finally, if you have something that executes async using a Future:

example from in-progress library Jester @ Git

usingAsync(new SafeReceivePort(), (SafeReceivePort safePort) {
  SendPort sendPort = safePort.toSendPort();
  sendPort.send('stuff');
  return safePort.messages.first; // Return any future here
})
.then((dynamic message) {
  ... message should be 'stuff'
  ... SafeReceivePort will be cleaned up for you, no need to remember to close
});

Goals #

  • Provide a mechanism to help manage cleanup in applications.
  • Originated as a way to help ensure closure of isolate ReceivePorts
  • Provide using semantics to auto dispose elements through scope

Version #

0.1.0 ish

Tech #

  • [Dart] - Dartlang.org: get the JS out!
  • Disposable - An implementation of disposable for Dart.

Installation #

License #

https://github.com/Vizidrix/disposable/blob/master/LICENSE


Edited #

  • 26-April-2013 initial release
  • 28-April-2013 bumped to 0.1.0

Credits #

0
likes
0
points
17
downloads

Publisher

unverified uploader

Weekly Downloads

An implementation of disposable for Dart.

Repository (GitHub)
View/report issues

Documentation

Documentation

License

unknown (license)

More

Packages that depend on disposable