Skip to content
This repository has been archived by the owner on Dec 13, 2023. It is now read-only.

Introduce setState(fn) variant #33

Closed
LPGhatguy opened this issue Mar 3, 2018 · 0 comments · Fixed by #39
Closed

Introduce setState(fn) variant #33

LPGhatguy opened this issue Mar 3, 2018 · 0 comments · Fixed by #39
Labels
feature: planned A feature that's been accepted into the project's roadmap.
Milestone

Comments

@LPGhatguy
Copy link
Contributor

In order to implement asynchronous rendering (#18), we need to make sure there's an API in place that mirror's React's setState variant that accepts a function.

Dependent updates work just fine right now, which means this code that works today would not work with asynchronous rendering:

setState(self.state.value + 1)

Instead, we should introduce a new API and encourage users to use it today:

setState(function(props, state)
    return {
        value = state.value + 1
    }
end)

Once work on async rendering begins, we can start catching cases where users call setState multiple times in a row synchronously to try to weed out dependent state mutations.

@LPGhatguy LPGhatguy added the feature: planned A feature that's been accepted into the project's roadmap. label Mar 3, 2018
@LPGhatguy LPGhatguy added this to the 1.0 milestone Mar 3, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
feature: planned A feature that's been accepted into the project's roadmap.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant