IOpenable

Interface that allows you to create components with explicit opening and closing.

Implements: IClosable

Description

The IOpenable interface allows you to create components with explicit opening and closing.

Important points

  • For components that perform opening on demand consider using IClosable interface instead.

Instance methods

isOpen

Checks if the component is open.

bool isOpen()

  • returns: bool - true if the component is open and false otherwise.

open

Opens the component.

Future open(String? correlationId)

  • correlationId: String? - (optional) transaction id used to trace execution through the call chain.

Examples

class MyPersistence implements IOpenable {
    dynamic _client;
    ...
    bool isOpen() {
        return _client != null;
    }
    Future open(String? correlationId) {
        if (isOpen()) {
            return Future(Duration(), (){
             })
        }
        ...
    }
    Future close(String? correlationId) async {
        if (_client != null) {
            result = await _client.close();
            _client = null;
           Future(Duration(), (){ return result})
        }
    }
    ...
}

See also