NullVoxPopuli / ember-resources

An implementation of Resources. Supports ember 3.28+
https://github.com/NullVoxPopuli/ember-resources/blob/main/docs/docs/README.md
MIT License
91 stars 37 forks source link

Explore options for using plain functions instead of resourceFactory #993

Open NullVoxPopuli opened 11 months ago

NullVoxPopuli commented 11 months ago

In pairing with folks, resourceFactory is juuust clunky enough to create a knowledge cliff in learning resources

For clarification this is the removal of resourceFactory in

const Timer = resourceFactory(updateMs => {
  return resource(() => {
    setInterval(() => { /* ... */ }, updateMs);
  });
});

and enabling this

function Timer(updateMs) {
  return resource(() => {
    setInterval(() => { /* ... */ }, updateMs);
  });
}

This has the benefit of:

Sample babel Plugin: https://astexplorer.net/#/gist/1833c986a7167eba0875eaf100a11adb/fb2cb060d563818908747ea2959886c837988759

Options: