Last active
November 11, 2017 16:24
-
-
Save toranb/7351d10173a0b73c946e71eecdd74298 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 Component, { tracked } from '@glimmer/component'; | |
import { createStore } from 'redux'; | |
const reducers = (state, action) => { | |
if(action.type === 'ADD') { | |
return state + 1; | |
} | |
return state || 0; | |
}; | |
const store = createStore(reducers); | |
export default class Demo extends Component { | |
@tracked _num; | |
@tracked('_num') | |
get num() { | |
return store.getState(); | |
} | |
constructor(args) { | |
store.subscribe(() => { | |
this._num = store.getState(); | |
}); | |
super(args); | |
} | |
add() { | |
store.dispatch({type: 'ADD'}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment