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

update-state, transact without passing this #46

Open
petterik opened this issue Jun 13, 2018 · 1 comment
Open

update-state, transact without passing this #46

petterik opened this issue Jun 13, 2018 · 1 comment

Comments

@petterik
Copy link
Owner

Could add new functions for interacting with a component that doesn't have to pass this

Example:

;; instead of:
(dom/button #js {:onClick #(la/update-state! this (fn [state] (assoc state :foo :bar)))})
;; Could have:
(dom/button #js {:onClick (la/update-state #(assoc % :foo :bar))})

Notice that:

  • update-state returns a function and that this is gone.
  • an anonymous function can be used to update the state, since the # char is not used to create an anonymous function.
  • the function has the bang ! removed. Not sure if that's good naming.

Same for transact, possibly for the computed functions as well and others?

@petterik
Copy link
Owner Author

Might want to bind additional *props* and *state* vars as well, to access reads and state without passing this. Examples:

(la/read :people)
(la/state :foo)

Not sure if this is useful though.

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

No branches or pull requests

1 participant