Skip to content

Instantly share code, notes, and snippets.

@toranb
Last active November 11, 2017 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save toranb/7351d10173a0b73c946e71eecdd74298 to your computer and use it in GitHub Desktop.
Save toranb/7351d10173a0b73c946e71eecdd74298 to your computer and use it in GitHub Desktop.
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