Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Explore options for using plain functions instead of resourceFactory #993

Open
NullVoxPopuli opened this issue Sep 19, 2023 · 0 comments · May be fixed by #994
Open

Explore options for using plain functions instead of resourceFactory #993

NullVoxPopuli opened this issue Sep 19, 2023 · 0 comments · May be fixed by #994

Comments

@NullVoxPopuli
Copy link
Owner

NullVoxPopuli commented Sep 19, 2023

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant