diff options
author | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-07 00:33:47 +0100 |
---|---|---|
committer | Bernhard Posselt <nukeawhale@gmail.com> | 2013-02-07 00:33:47 +0100 |
commit | 57c70e9b7828590219b197a58abc11515a45fbd7 (patch) | |
tree | 5ef6ab1a7c111004ab16c11ad70b0f6999e630bd /coffee/lib/services/publisher.coffee | |
parent | 151527c2649af40b22aaba76166e06eb0a274b22 (diff) |
test
Diffstat (limited to 'coffee/lib/services/publisher.coffee')
-rw-r--r-- | coffee/lib/services/publisher.coffee | 74 |
1 files changed, 37 insertions, 37 deletions
diff --git a/coffee/lib/services/publisher.coffee b/coffee/lib/services/publisher.coffee index 4d8788726..39d4ddd43 100644 --- a/coffee/lib/services/publisher.coffee +++ b/coffee/lib/services/publisher.coffee @@ -15,40 +15,40 @@ angular.module('OC').factory '_Publisher', -> - class Publisher - - constructor: -> - @subscriptions = {} - - - # Use this to subscribe to a certain hashkey in the returned json data - # dictionary. - # If you send JSON from the server, you'll receive something like this - # - # { - # data: { - # modelName: { - # create: [{id: 1, name: 'john'}, {id: 2, name: 'ron'}], - # update: [], - # delete: [] - # } - # } - # } - # - # To get the array ['one', 'two'] passed to your model, just subscribe - # to the key: - # Publisher.subscribeModelTo('modelName', myModelInstance) - # - subscribeModelTo: (model, name) -> - @subscriptions[name] or= [] - @subscriptions[name].push(model) - - - # This will publish data from the server to all registered subscribers - # The parameter 'name' is the name under which subscribers have registered - publishDataTo: (data, name) -> - for subscriber in @subscriptions[name] || [] - subscriber.handle(data) - - - return Publisher
\ No newline at end of file + class Publisher + + constructor: -> + @subscriptions = {} + + + # Use this to subscribe to a certain hashkey in the returned json data + # dictionary. + # If you send JSON from the server, you'll receive something like this + # + # { + # data: { + # modelName: { + # create: [{id: 1, name: 'john'}, {id: 2, name: 'ron'}], + # update: [], + # delete: [] + # } + # } + # } + # + # To get the array ['one', 'two'] passed to your model, just subscribe + # to the key: + # Publisher.subscribeModelTo('modelName', myModelInstance) + # + subscribeModelTo: (model, name) -> + @subscriptions[name] or= [] + @subscriptions[name].push(model) + + + # This will publish data from the server to all registered subscribers + # The parameter 'name' is the name under which subscribers have registered + publishDataTo: (data, name) -> + for subscriber in @subscriptions[name] || [] + subscriber.handle(data) + + + return Publisher
\ No newline at end of file |