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

Auto detect state | deprecate helper #16

Closed
ECorreia45 opened this issue May 14, 2024 · 0 comments · Fixed by #17
Closed

Auto detect state | deprecate helper #16

ECorreia45 opened this issue May 14, 2024 · 0 comments · Fixed by #17
Assignees
Labels
enhancement New feature or request

Comments

@ECorreia45
Copy link
Contributor

ECorreia45 commented May 14, 2024

By using signals algorithm for detecting effects
We can automatically detect states even inside functions. This means

  • removing the need for states to be function arguments for the function to be reactive
  • state getter to be a internally subscribable function
  • any function that uses state internally used inside the template to be reactive by default which means no need to wrap a function with helper.
onStateUpdate(() => {
  // handle
}) // <- can even consider adding list of states to react to

when(() => someState() > 2, ...) // would be reactive

What happens to helper/Helper?

If after this there is no usage, it can be deprecated.

Bonus

  • Introduce the onStateUpdate and make the second argument be a "reducer" type of function that the returned value is kept. This means, deprecating state unsubscriber.
  • Memoize state values and do shallow comparisons before broadcasting
  • Make state a standalone part
@ECorreia45 ECorreia45 added the enhancement New feature or request label May 14, 2024
@ECorreia45 ECorreia45 self-assigned this May 14, 2024
@ECorreia45 ECorreia45 changed the title Auto detect state Auto detect state | deprecate helper May 14, 2024
@ECorreia45 ECorreia45 linked a pull request May 31, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant