• This is not a core part of ember-resources, but is an example utility to demonstrate a concept when authoring your own resources. However, this utility is still under the broader library's SemVer policy.

    A consuming app will not pay for the bytes of this utility unless imported.

    Native fetch but with built-in AbortController

    example with composition (maybe you want to implement your own version that also wraps up authorization headers):

    import { tracked } from '@glimmer/tracking';
    import { use, resource } from 'ember-resources';
    import { remoteData } from 'ember-resources/util/remote-data';

    class Demo {
    @tracked id = 1;

    @use myData = resource((hooks) =>
    remoteData(hooks, `https://...${this.id}`)
    );
    }

    The same example, but without @use

    import { tracked } from '@glimmer/tracking';
    import { resource } from 'ember-resources';
    import { remoteData } from 'ember-resources/util/remote-data';

    class Demo {
    @tracked id = 1;

    myData = resource(this, (hooks) =>
    remoteData(hooks, `https://...${this.id}`)
    );
    }

    Type Parameters

    • T = unknown

    Parameters

    • __namedParameters: ResourceAPI
    • url: string
    • options: undefined | RequestInit = {}

    Returns State<T>

Generated using TypeDoc