Sha256: 8b7162adc98aecbbf07911eb624df252992389f598c384b8dfdc712618a1b47a

Contents?: true

Size: 603 Bytes

Versions: 4

Compression:

Stored size: 603 Bytes

Contents

# = require angular

angular.module "faye", []

angular.module("faye").factory "$faye", ["$q", "$rootScope", ($q, $rootScope) ->
  (url) ->
    scope = $rootScope
    client = new Faye.Client(url)
    publish: (channel, data) ->
      client.publish channel, data

    subscribe: (channel, callback) ->
      client.subscribe channel, (data) ->
        scope.$apply ->
          callback(data)

    get: (channel) ->
      deferred = $q.defer()
      sub = client.subscribe(channel, (data) ->
        scope.$apply ->
          deferred.resolve data
        sub.cancel()
      )
      deferred.promise
]

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
angular-faye-rails-0.1.0.4 vendor/assets/javascripts/angular-faye.js.coffee
angular-faye-rails-0.1.0.3 vendor/assets/javascripts/angular-faye.js.coffee
angular-faye-rails-0.1.0.2 vendor/assets/javascripts/angular-faye.js.coffee
angular-faye-rails-0.1.0.1 vendor/assets/javascripts/angular-faye.js.coffee