View actions.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Store } from 'laco' | |
const CounterStore = new Store({ count: 0 }, "CounterStore") | |
// Implementing some actions to update the store | |
const increment = () => CounterStore.set(state => ({ count: state.count + 1 }), "Increment"); | |
const decrement = () => CounterStore.set(state => ({ count: state.count - 1 }), "Decrement"); |
View counterStore.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Store } from 'laco' | |
const CounterStore = new Store({ count: 0 }, "CounterStore") |
View globalstate.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Store, getGlobalState } from 'laco' | |
const CounterStore = new Store({ count: 0 }) | |
const ToggleStore= new Store({ toggle: false }) | |
getGlobalState() | |
// Outputs an object: | |
// { | |
// "0": { count: 0 }, | |
// "1": { toggle: false }, |
View Counter.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { render } from 'react-dom' | |
import { Store } from 'laco' | |
import { Subscribe } from 'laco-react' | |
// Creating a new store with an initial state { count: 0 } | |
const CounterStore = new Store({ count: 0 }) | |
// Implementing some actions to update the store | |
const increment = () => CounterStore.set(state => ({ count: state.count + 1 })) | |
const decrement = () => CounterStore.set(state => ({ count: state.count - 1 })) |
View gist:bc59305eeeba0810083575fe9b734543
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### Keybase proof | |
I hereby claim: | |
* I am deamme on github. | |
* I am deam (https://keybase.io/deam) on keybase. | |
* I have a public key ASDru6OJKPBP2_Oio9EIWvW3BZsECn8QDMpkBLGjs3M9_Qo | |
To claim this, I am signing this object: |