Skip to content

Instantly share code, notes, and snippets.

@adamrneary
Last active August 29, 2015 14:11
Show Gist options
  • Select an option

  • Save adamrneary/a4a09bcefcd3858a35f8 to your computer and use it in GitHub Desktop.

Select an option

Save adamrneary/a4a09bcefcd3858a35f8 to your computer and use it in GitHub Desktop.
React/Firebase/Odometer prototype
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