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

Global access to state/actions in actions/components #615

Closed
jason-whitted opened this issue Feb 21, 2018 · 1 comment
Closed

Global access to state/actions in actions/components #615

jason-whitted opened this issue Feb 21, 2018 · 1 comment

Comments

@jason-whitted
Copy link

Slices are convenient when they are helping you out, but they very frequently impede the developer from being able to accomplish a goal. This is a recurring theme as seen in:

I have experimented with hyperapp over at etalisoft/hyperapp-extended to get this to work.

It modifies the following signatures:

// action signature
value => (state, actions, current) => ...
// component signature
(attributes, children, current) => ...

current is an object with the following methods:

  • getState() - returns the global state
  • getActions() returns the global actions

This allows both actions and components the flexibility to have access to current state/actions even in nested async callbacks.

The current object is only created once and frozen and merely passed along as an additional argument, which should have no negative performance impact.

@jorgebucaran
Copy link
Owner

Closed in favor of #606.

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

2 participants