CCC Docs
    Preparing search index...

    Class Owner<T>Abstract

    Owns the lifecycle of a value.

    class ConnectionOwner extends Owner<Connection> {
    constructor(protected readonly value_: Connection) {
    super();
    }

    protected release(connection: Connection): Promise<void> {
    return connection.close();
    }
    }

    Type Parameters

    • T

    Hierarchy (View Summary)

    Index
    value_: T
    • get value(): T

      The owned value.

      Returns T

      If this ownership has been moved or disposed.

    • Returns whether a value implements CCC Owner semantics.

      Parameters

      • value: unknown

      Returns value is Owner<unknown>

    • Releases this ownership claim.

      Implementations decide whether this disposes the value immediately or, for example, only decrements a reference count.

      Parameters

      • value: T

      Returns void | PromiseLike<void>

    • Disposes this ownership claim. Repeated calls are safe.

      Returns Promise<void>

    • Maps the owned value while transferring this ownership claim.

      The mapper runs before the claim is moved, so a mapper failure leaves this Owner active. After a successful mapping, this Owner is invalidated and the returned Owner retains its release semantics.

      Type Parameters

      • U

      Parameters

      • mapper: (value: T) => U

      Returns Owner<U>

    • Moves the ownership claim out of this owner without disposing it.

      Access is invalidated synchronously and the moved claim retains this Owner's release semantics.

      Returns OwnerMoved<T>

      If this owner no longer has an ownership claim.