Skip to main content

Home > flowp > delegate

delegate() function

Delegates method calls and member access to the resolved value

not verified in production use

Signature:

export declare function delegate<T extends Promise<unknown>>(value: T): Delegated<T>;

Parameters

ParameterTypeDescription
valueTvalue to delegate to, must be a promise and should not be resolved with primitives

Returns:

Delegated<T>

the delegated object, access delegated properties with ${key}

Example

const promise = Promise.resolve({ foo: { bar: 'baz' } })
const delegated = delegate(promise)
await delegated.$foo.$bar // 'baz'