Skip to content

Explore options for using plain functions instead of resourceFactory #993

@NullVoxPopuli

Description

@NullVoxPopuli

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:

  • being one less abstraction
  • enabling generics in TS

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

Options:

  • Babel plugin
    • how do we support both modifiers
      • won't work with TS without integrating with Glint
    • and non-modifiers?
  • Opt-in re-registration of "default" managers

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions