React = require 'react' NotificationStore = require './notifications-store' class Notifications extends React.Component @displayName: "Notifications" constructor: (@props) -> @state = 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() module.exports = Notifications