IClosable

Interface that allows you to create a component with a method that closes it and frees used resources.

Description

The IClosable interface allows you to create a component with a method that closes it and frees used resources.

Instance methods

close

Closes a component and frees used resources.

Future close(IContext? context)

  • context: IContext - (optional) a context to trace execution through a call chain.

Examples

class MyConnector implements IClosable {
    dynamic _client = null;
    ... // The _client can be lazy created
    Future close(IContext? context){
        if (_client != null) {
            _client.close();
            _client = null;
        }
        return  Future.delayed( Duration());
    }
}

See also