IOpenable

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

Extends: 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 opened.

public isOpen(): boolean

  • returns: boolean - true if the component has been opened and false otherwise.

open

Opens the component.

open(context: IContext): Promise<void>

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

Examples

	type MyPersistence {
			_client any
		}

		func (mp* MyPersistence)IsOpen() bool {
			return mp._client != nil;
		}

		func (mp* MyPersistence) Open(ctx context.Context) error {
			if (mp.isOpen()) {
				return nil;
			}
		}

		func (mp* MyPersistence) Close(ctx context.Context) {
			if (mp._client != nil) {
				mp._client.Close(ctx);
				mp._client = nil;
			}
		}

See also