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

Refactor how signals are created. #27

Open
cesarParra opened this issue Dec 7, 2024 · 0 comments
Open

Refactor how signals are created. #27

cesarParra opened this issue Dec 7, 2024 · 0 comments

Comments

@cesarParra
Copy link
Owner

Having to delete properties out of the signal before returning it is not a great developer experience

// We don't want to expose the `get` and `set` methods, so

This can cause issues of us leaking information that we didn't intend if we forget to delete a new property in the future that should not be returned.

The main use case we have is that we allow for custom storages to add additional functionality to the signals. For example, here https://github.com/cesarParra/lwc-signals/blob/main/src/lwc/signals/__tests__/custom-storage.test.ts#L44 we created a custom storage that allows for the undo function to be added to the signal. This is something we want to continue to support.

What we want to accomplish here is:

  • Prevent having to delete properties when creating signals
  • Continue to allow for custom functions to be added to signals
  • Update the Typescript types to correctly represent what the signal has, including if possible the custom functions.

Ideas

  • We can change the way that adding custom functions work. It can be pretty cumbersome to have to create a new storage for this. Instead we can allow for custom Mixins to be created. The Dart Signals implementation does this https://dartsignals.dev/mixins/signals-mixin/
    ** Dart has mixin support at the language level, so it is elegant to do it in that language, how would that look in TS/JS?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant