Options
All
  • Public
  • Public/Protected
  • All
Menu

Module util/function-resource

Index

Type aliases

Hooks: { on: { cleanup: any } }

Type declaration

  • on: { cleanup: any }
    • cleanup:function
      • cleanup(destroyer: Destructor): void
      • Optionally a function-resource can provide a cleanup function.

        Example:

        import { resource } from 'ember-resources/util/function-resource';
        import { TrackedObject } from 'tracked-built-ins';

        const load = resource(({ on }) => {
        let state = new TrackedObject({});
        let controller = new AbortController();

        on.cleanup(() => controller.abort());

        fetch(this.url, { signal: controller.signal })
        // ...

        return state;
        })

        Parameters

        • destroyer: Destructor

        Returns void

Functions

  • registerResourceWrapper(wrapperFn: ResourceFactory): ResourceFactory
  • Allows wrapper functions to provide a resource for use in templates.

    Only library authors may care about this, but helper function is needed to "register" the wrapper function with a helper manager that specifically handles invoking both the resource wrapper function as well as the underlying resource.

    App-devs / consumers may not ever need to know this utility function exists

    Example using strict mode +