React = require 'react' NotificationStore = require './notifications-store' module.exports = Notifications = React.createClass getInitialState: -> notifications: NotificationStore.notifications() componentDidMount: -> @unsubscribeStore = NotificationStore.listen @_onStoreChange componentWillUnmount: -> @unsubscribeStore() if @unsubscribeStore render: ->
{@_notificationComponents()}
_notificationComponents: -> @state.notifications.map (notification) ->
{notification.message}
_onStoreChange: -> @setState notifications: NotificationStore.notifications()