Reactive models based on ES6 classes and Vuex.
Vue-Spine aims to replace
fetchPostById
/updatePost
Vuex mutations/actions with a DRYed up model API likePost.find
orpost.update
.
- ES6 classes
- Vuex modules
- API with expandability in mind
- REST support
- Other backends (e.g. LocalStorage) easily possible
- Spine.js / Backbone.js
- Rails ActiveRecord
- Backwards compatibility
// models/post.js
import { RestModel } from 'vue-spine'
class Post extends RestModel {
static get attributes () {
return [
'title',
'content',
{
name: 'comment_ids',
association: 'hasMany'
}
]
}
}
export default Post
Post.find(1)
Post.findBy('title', 'Vue-Spine talk')
Post.findAllBy('title', 'Vue-Spine talk')
Post.exists()
Post.all()
Post.load()
...
post.title = 'Update title'
post.save
post.comments
...
- Vuex modules
- Object.defineProperty (ES6 Proxy Traps?)
- Vuex "wrapper"
- ES6 class inheritance / extends
- PoC
- Presentation
- Feedback
- Github issues / TODOs
- Real world usage 🚀