For use in the body of a class.
For use in the body of a class.
from is what allows resources to be used in JS, they hide the reactivity APIs
from the consumer so that the surface API is smaller.
Unlike of, due to the fewer arguments required in from, though it may be more
convenient to not wrap your resource abstraction in a helper function.
import { Resource } from 'ember-resources';
class SomeResource extends Resource {}
class MyClass {
data = SomeResource.from(this, () => [ ... ]);
}
However, if you have argument defaults or need to change the shape of arguments depending on what ergonomics you want your users to have, a wrapper function may be better.
export function someResource(context, { foo, bar }) {
return SomeResource.from(context, () => ... );
}
usage:
import { someResource } from 'your-library';
class SomeResource extends Resource {}
class MyClass {
@tracked foo;
@tracked bar;
data = someResource(this, {
foo: () => this.foo,
bar: () => this.bar
});
}
Generated using TypeDoc
For use in the body of a class.