File tree 2 files changed +6
-6
lines changed
2 files changed +6
-6
lines changed Original file line number Diff line number Diff line change 1
- source : rubygems
1
+ source 'http:// rubygems.org'
2
2
3
3
group :development do
4
4
gem "RedCloth" , "~> 4.2"
Original file line number Diff line number Diff line change 1
1
---
2
- layout : recipe Observer Pattern
2
+ layout : recipe
3
3
title : Observer Pattern
4
4
chapter : Design patterns
5
5
---
@@ -20,7 +20,7 @@ class PostOffice
20
20
subscriber.callback(item) for subscriber in @subscribers when subscriber.item is item
21
21
subscribe: (to, onNewItemReleased) ->
22
22
@subscribers .push {'item': to , 'callback': onNewItemReleased }
23
-
23
+
24
24
class MagazineSubscriber
25
25
onNewMagazine: (item) ->
26
26
alert "I've got new "+item
@@ -41,7 +41,7 @@ postOffice.notifyNewItemReleased "Mens Health"
41
41
42
42
## Discussion
43
43
44
- Here you have an observer object (PostOffice) and observable objects (MagazineSubscriber, NewspaperSubscriber).
45
- To be notified about an event of publishing new periodical observable object should make subscribtion on PostOffice.
46
- Every of subscribed objects is stored internaly in the PostOffice array of subscribtions.
44
+ Here you have an observer object (PostOffice) and observable objects (MagazineSubscriber, NewspaperSubscriber).
45
+ To be notified about an event of publishing new periodical observable object should make subscribtion on PostOffice.
46
+ Every of subscribed objects is stored internaly in the PostOffice array of subscribtions.
47
47
Every subscriber is notified on new concrete periodical is published.
You can’t perform that action at this time.
0 commit comments