$ = jQuery
context = window
logger = context.JK.logger
broadcastActions = context.JK.Actions.Broadcast

rest = context.JK.Rest()

broadcastActions.load.listenAndPromise(rest.getBroadcastNotification);

BroadcastStore = Reflux.createStore(
  {
    listenables: broadcastActions

    onLoad: () ->
      logger.debug("loading broadcast notification...")

    onLoadCompleted: (response) ->
      logger.debug("broadcast notification sync completed")
      this.trigger(response)

    onLoadFailed: (jqXHR) ->
      if jqXHR.status != 404
        logger.error("broadcast notification sync failed")

    onHide: () ->
      this.trigger(null)
  }
)

context.JK.Stores.Broadcast = BroadcastStore

