IOpenable class

Interface for components that require explicit opening and closing.

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

See IOpenable See Opener

Example

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

             })
        }
        ...
    }
    
    Future close(String correlationId) async {
        if (this._client != null) {
            result = await this._client.close();
            this._client = null;
           Future(Duration(), (){ return result})
        } 
    }
   
    ...
}
Implemented types

Constructors

IOpenable()

Properties

hashCode → int
The hash code for this object. [...]
read-only, inherited
runtimeType → Type
A representation of the runtime type of the object.
read-only, inherited

Methods

isOpen() → bool
  • Checks if the component is opened.
    • Returns true if the component has been opened and false otherwise.
  • open(String correlationId) → Future
  • Opens the component.
      • correlationId (optional) transaction id to trace execution through call chain.
    • Return Future that receives error or null no errors occured.
  • close(String correlationId) → Future
  • Closes component and frees used resources.
      • correlationId (optional) transaction id to trace execution through call chain.
    • Return Future that receives error or null no errors occured.
  • inherited
    noSuchMethod(Invocation invocation) → dynamic
    Invoked when a non-existent method or property is accessed. [...]
    inherited
    toString() → String
    Returns a string representation of this object.
    inherited

    Operators

    operator ==(dynamic other) → bool
    The equality operator. [...]
    inherited