Skip to content

Commit

Permalink
refactor(core): simplify functions
Browse files Browse the repository at this point in the history
  • Loading branch information
tusharmath committed Sep 5, 2016
1 parent 2511e55 commit 45d63ed
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/createWCProto.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,25 +57,26 @@ export default (virtualDOMPatcher, component) => {
this.__handlers = {}
this.__props = {}
this.__dispatchActions = this.__dispatchActions.bind(this)
this.__render = this.__render.bind(this)

props.forEach(p => {
Object.defineProperty(this, p, {
get: () => this.__props[p],
set: (value) => {
this.__props[p] = value
this.__dispatchActions(`@@prop/${p}`)(value)
set: (params) => {
this.__props[p] = params
this.__store.dispatch({type: `@@prop/${p}`, params})
}
})
})

this.__patch = virtualDOMPatcher(this.attachShadow({mode: 'open'}))
this.__store = createStore(this.__reducer.bind(this), init(this))
this.__render()
this.__dispose = this.__store.subscribe(() => this.__render())
this.__dispose = this.__store.subscribe(this.__render)
},

attachedCallback () {
this.__dispatchActions('@@attached')(this)
this.__store.dispatch({type: '@@attached', params: this})
},

detachedCallback () {
Expand Down

0 comments on commit 45d63ed

Please sign in to comment.