Revue
Learn Redux before using Revue. That would help you get rid of JavaScript fatigue, sort of.
Usage
Obviously it works with Redux, install via NPM: npm i --save redux revue
You can also hot-link the CDN version: https://npmcdn.com/revue/dist/revue.js, Revue
is exposed to window
object.
The Gist
You can try it online! http://esnextb.in/?gist=b300931ac26da8e9de2f
store.js
// create the logic how you would update the todos// create some redux actions // create a redux storeconst reduxStore = // binding the store to Vue instance, actions are optionalconst store = Vue reduxStore actions// expose the store for your component to use
actions/todos.js
// create actionCreators yourself or use `redux-actions` { return type: 'ADD_TODO' payload} { return type: 'TOGGLE_TODO' payload}
component.js
When creating a Vue component that needs to react to data from Redux's store, you must specify the bindings between the data of the component and the data in the store. The following is an example of binding the data todo
in the component with store.getState().todos
by using the special function this.$select('todos')
.
{ return todo: '' todos: this //=> subscribe state.todos to vm.todos // if prop is not in top level // do this.$select('todos as path.to.todos') } methods: { store // or use the actionCreator store // also equal to: (if you binded actions when creating the store) const addTodo = storeactions store }
Recipes 🍳
Development
- npm test run unit test
- npm run example run webpack example
License
MIT © EGOIST