Last active
August 29, 2015 14:11
-
-
Save adamrneary/a4a09bcefcd3858a35f8 to your computer and use it in GitHub Desktop.
React/Firebase/Odometer prototype
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| React = require('react') | |
| Firebase = require('firebase') | |
| ReactFireMixin = require('reactfire') | |
| OdometerComponent = require('react-odometer') | |
| firebaseApp = 'https://luminous-heat-2841.firebaseio.com/' | |
| projectId = location.hash.substring(1) or 324 | |
| ViewCount = React.createClass | |
| mixins: [ReactFireMixin] | |
| getInitialState: -> | |
| data: | |
| name: '…loading…' | |
| events: {'Video View': 10000} | |
| componentWillMount: -> | |
| @bindAsObject new Firebase("#{firebaseApp}project/#{projectId}"), 'data' | |
| render: -> | |
| React.DOM.div {id: 'viewCount'}, | |
| React.DOM.h3(null, @state.data.name), | |
| React.createElement OdometerComponent, | |
| value: @state.data.events['Video View'] | |
| React.renderComponent React.createElement(ViewCount, {projectId: projectId}), | |
| document.getElementById('content') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment