Skip to content

Commit 6ece9c6

Browse files
committed
Exercise 4.5
1 parent 779401b commit 6ece9c6

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

4-state-management/4.5-functional.html

+19-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,25 @@
44

55
<script>
66
function app ({ el, model, view, actions }) {
7-
// Implement this!
7+
const wrappedActions = {}
8+
9+
Object.keys(actions).forEach(key => {
10+
const originalAction = actions[key]
11+
wrappedActions[key] = () => {
12+
vm.model = originalAction(vm.model)
13+
}
14+
})
15+
16+
const vm = new Vue({
17+
el,
18+
data: {
19+
model
20+
},
21+
render (h) {
22+
return view(h, this.model, wrappedActions)
23+
},
24+
methods: actions
25+
})
826
}
927

1028
// voila

0 commit comments

Comments
 (0)