Skip to content

Commit

Permalink
use functional components for uptime bench
Browse files Browse the repository at this point in the history
  • Loading branch information
yyx990803 committed Jul 31, 2016
1 parent 4f2537a commit dfd309e
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions benchmarks/uptime/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,18 @@
</div>
<script src="../../dist/vue.min.js"></script>
<script>
// functional components are prefect for small, presentational components
// and they are much more efficient than stateful ones.
Vue.component('uptime-day', {
props: ['day'],
template: `
<div class="uptime-day">
<span class="uptime-day-status" :style="{ backgroundColor: day.up ? '#8cc665' : '#ccc' }"></span>
<span class="hover">{{day.number}}: {{day.up ? 'Servers operational!' : 'Red alert!'}}</span>
</div>
`
functional: true,
render (h, ctx) {
var day = ctx.props.day
return h('div', { staticClass: 'uptime-day'}, [
h('span', { staticClass: 'uptime-day-status', style: { backgroundColor: day.up ? '#8cc665' : '#ccc' } }),
h('span', { staticClass: 'hover' }, [day.number + ': ' + day.up ? 'Servers operational!' : 'Red alert!'])
])
}
})

Vue.component('server-uptime', {
Expand Down Expand Up @@ -187,7 +191,7 @@ <h2>Biggest Streak: {{maxStreak}}</h2>
app.fps = Math.round(fpsMeter.push(1000 / (thisFrame - lastFrame)))
}
app.servers = Object.freeze(generateServers())
loop = requestAnimationFrame(update)
loop = setTimeout(update, 0) // not using rAF because that limits us to 60fps!
lastFrame = thisFrame
}
</script>
Expand Down

0 comments on commit dfd309e

Please sign in to comment.