redux-zero / redux-zero

A lightweight state container based on Redux

Home Page:https://matheusml1.gitbooks.io/redux-zero-docs/content/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Proper syntax for store.setState callback?

x8BitRain opened this issue · comments

What is the proper syntax for calling a function once the store has been updated? In React with setState you can do

this.setState({ thing: "thing" }, () => { console.log("thing was set!") })

But this doesn't appear to work the same way with store.setState(), I can also do

(async () => {
    await store.setState({
        thing: "thing"
    });
    console.log("thing set!")
})();

But I'm not sure if there's syntax that I don't know about that does the same without having to use async await.

Thanks!