use<R> method

Future<R> use<R>(
  1. Future<R> block(
    1. Resource resource
    )
)
inherited

Executes the given block function on this resource and then closes it down correctly whether an exception is thrown or not.

Implementation

Future<R> use<R>(Future<R> Function(Resource resource) block) async {
  try {
    return block(this);
  } on Exception {
    rethrow;
  } finally {
    await close();
  }
}