Function use

  • use(_prototype: object, key: string, descriptor?: Descriptor): void
  • The @use decorator has two responsibilities

    • abstract away the underlying reactivity configuration (invokeHelper)
      • by doing this, we get destruction-association properly cofigured so that when the host class is destroyed, if the resource has a destructor, it will be called during destruction
    • allows the return value of the resource to be "the" value of the property.

    This @use decorator is needed for function-resources, and not needed for class-based resources (for now).

    Example

    import { resource, use } from 'ember-resources';

    class MyClass {
    @use data = resource(() => {
    return 2;
    });
    }

    (new MyClass()).data === 2

    Parameters

    • _prototype: object
    • key: string
    • Optional descriptor: Descriptor

    Returns void

Generated using TypeDoc