Permalink
Browse files

Mixin.Observable: renamed addSubscription to publishSubscription to m…

…ake its purpose more clear
  • Loading branch information...
1 parent 0804716 commit 3c80bc3f452751d965047c25fbdf865b7e6daf72 Kevin Malakoff committed Dec 10, 2011
View
@@ -117,7 +117,7 @@ Provides ways to manage flags and to get a callback when they change.
Provides ways some basic reference counting and to get a callback when your instance is released.
## Subscriptions
-Provides a way to publish subscriptions (addSubscription) and notify subscribers when they change. You can mixin: Observable, Subscriber or ObservableSubscriber.
+Provides a way to publish subscriptions (publishSubscription) and notify subscribers when they change. You can mixin: Observable, Subscriber or ObservableSubscriber.
-> this give a more advanced example of what is possible.
## Timeouts
@@ -152,7 +152,7 @@ Mixin.Subscriptions.Observable._mixin_info = {
_results = [];
for (_i = 0, _len = arguments.length; _i < _len; _i++) {
arg = arguments[_i];
- _results.push(this.addSubscription.apply(this, _.isArray(arg) ? arg : [arg]));
+ _results.push(this.publishSubscription.apply(this, _.isArray(arg) ? arg : [arg]));
}
return _results;
},
@@ -178,15 +178,15 @@ Mixin.Subscriptions.Observable._mixin_info = {
instance_data = Mixin.instanceData(this, 'Observable');
return instance_data.subscriptions.hasOwnProperty(subscription_name);
},
- addSubscription: function(subscription_name, subscription_type) {
+ publishSubscription: function(subscription_name, subscription_type) {
var instance_data;
instance_data = Mixin.instanceData(this, 'Observable');
if (subscription_type === void 0) {
subscription_type = Mixin.Subscription.TYPE.MULTIPLE;
}
if (Mixin.DEBUG) {
- Mixin.Core._Validate.string(subscription_name, 'Mixin.Observable.addSubscription', 'subscription_name');
- Mixin.Core._Validate.noKey(instance_data.subscriptions, subscription_name, 'Mixin.Observable.addSubscription', 'subscription_name');
+ Mixin.Core._Validate.string(subscription_name, 'Mixin.Observable.publishSubscription', 'subscription_name');
+ Mixin.Core._Validate.noKey(instance_data.subscriptions, subscription_name, 'Mixin.Observable.publishSubscription', 'subscription_name');
}
instance_data.subscriptions[subscription_name] = new Mixin.Subscriptions._Subscription(this, subscription_type);
return this;

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -1,7 +1,7 @@
Mixin.Subscriptions Docs
********************
-This mixin provides a way to publish subscriptions (addSubscription) and notify subscribers when they change. You can mixin: Observable, Subscriber or ObservableSubscriber.
+This mixin provides a way to publish subscriptions (publishSubscription) and notify subscribers when they change. You can mixin: Observable, Subscriber or ObservableSubscriber.
TODO! for now, please study the tests in: test/mixin_subscriptions/mixin_subscriptions_tests.coffee
View
@@ -1578,7 +1578,7 @@ Mixin.Subscriptions.Observable._mixin_info = {
_results = [];
for (_i = 0, _len = arguments.length; _i < _len; _i++) {
arg = arguments[_i];
- _results.push(this.addSubscription.apply(this, _.isArray(arg) ? arg : [arg]));
+ _results.push(this.publishSubscription.apply(this, _.isArray(arg) ? arg : [arg]));
}
return _results;
},
@@ -1604,15 +1604,15 @@ Mixin.Subscriptions.Observable._mixin_info = {
instance_data = Mixin.instanceData(this, 'Observable');
return instance_data.subscriptions.hasOwnProperty(subscription_name);
},
- addSubscription: function(subscription_name, subscription_type) {
+ publishSubscription: function(subscription_name, subscription_type) {
var instance_data;
instance_data = Mixin.instanceData(this, 'Observable');
if (subscription_type === void 0) {
subscription_type = Mixin.Subscription.TYPE.MULTIPLE;
}
if (Mixin.DEBUG) {
- Mixin.Core._Validate.string(subscription_name, 'Mixin.Observable.addSubscription', 'subscription_name');
- Mixin.Core._Validate.noKey(instance_data.subscriptions, subscription_name, 'Mixin.Observable.addSubscription', 'subscription_name');
+ Mixin.Core._Validate.string(subscription_name, 'Mixin.Observable.publishSubscription', 'subscription_name');
+ Mixin.Core._Validate.noKey(instance_data.subscriptions, subscription_name, 'Mixin.Observable.publishSubscription', 'subscription_name');
}
instance_data.subscriptions[subscription_name] = new Mixin.Subscriptions._Subscription(this, subscription_type);
return this;
View

Large diffs are not rendered by default.

Oops, something went wrong.
@@ -95,7 +95,7 @@ Mixin.Subscriptions.Observable._mixin_info =
initialize: ->
Mixin.instanceData(this, 'Observable', {subscriptions: {}, is_destroyed: false})
- (@addSubscription.apply(this, if _.isArray(arg) then arg else [arg])) for arg in arguments
+ (@publishSubscription.apply(this, if _.isArray(arg) then arg else [arg])) for arg in arguments
destroy: ->
instance_data = Mixin.instanceData(this, 'Observable')
@@ -110,12 +110,12 @@ Mixin.Subscriptions.Observable._mixin_info =
instance_data = Mixin.instanceData(this, 'Observable')
return (instance_data.subscriptions.hasOwnProperty(subscription_name))
- addSubscription: (subscription_name, subscription_type) ->
+ publishSubscription: (subscription_name, subscription_type) ->
instance_data = Mixin.instanceData(this, 'Observable')
subscription_type = Mixin.Subscription.TYPE.MULTIPLE if (subscription_type == undefined)
if Mixin.DEBUG
- Mixin.Core._Validate.string(subscription_name, 'Mixin.Observable.addSubscription', 'subscription_name')
- Mixin.Core._Validate.noKey(instance_data.subscriptions, subscription_name, 'Mixin.Observable.addSubscription', 'subscription_name')
+ Mixin.Core._Validate.string(subscription_name, 'Mixin.Observable.publishSubscription', 'subscription_name')
+ Mixin.Core._Validate.noKey(instance_data.subscriptions, subscription_name, 'Mixin.Observable.publishSubscription', 'subscription_name')
instance_data.subscriptions[subscription_name] = new Mixin.Subscriptions._Subscription(this, subscription_type)
return this
@@ -162,35 +162,35 @@ $(document).ready(function() {
}), Error, "Mixin.Observable.hasSubscription: subscription_name invalid");
observable = new Observerable();
raises((function() {
- return observable.addSubscription();
- }), Error, "Mixin.Observable.addSubscription: subscription_name missing");
+ return observable.publishSubscription();
+ }), Error, "Mixin.Observable.publishSubscription: subscription_name missing");
raises((function() {
- return observable.addSubscription(0);
- }), Error, "Mixin.Observable.addSubscription: subscription_name invalid");
+ return observable.publishSubscription(0);
+ }), Error, "Mixin.Observable.publishSubscription: subscription_name invalid");
raises((function() {
- return observable.addSubscription({});
- }), Error, "Mixin.Observable.addSubscription: subscription_name invalid");
+ return observable.publishSubscription({});
+ }), Error, "Mixin.Observable.publishSubscription: subscription_name invalid");
raises((function() {
- return observable.addSubscription([]);
- }), Error, "Mixin.Observable.addSubscription: subscription_name invalid");
+ return observable.publishSubscription([]);
+ }), Error, "Mixin.Observable.publishSubscription: subscription_name invalid");
raises((function() {
- return observable.addSubscription(observable);
- }), Error, "Mixin.Observable.addSubscription: subscription_name invalid");
+ return observable.publishSubscription(observable);
+ }), Error, "Mixin.Observable.publishSubscription: subscription_name invalid");
raises((function() {
- return observable.addSubscription(Observerable);
- }), Error, "Mixin.Observable.addSubscription: subscription_name invalid");
+ return observable.publishSubscription(Observerable);
+ }), Error, "Mixin.Observable.publishSubscription: subscription_name invalid");
raises((function() {
- return observable.addSubscription('Hello', 42);
- }), Error, "Mixin.Observable.addSubscription: options invalid");
+ return observable.publishSubscription('Hello', 42);
+ }), Error, "Mixin.Observable.publishSubscription: options invalid");
raises((function() {
- return observable.addSubscription('Hello', []);
- }), Error, "Mixin.Observable.addSubscription: options invalid");
+ return observable.publishSubscription('Hello', []);
+ }), Error, "Mixin.Observable.publishSubscription: options invalid");
raises((function() {
- return observable.addSubscription('Hello', observable);
- }), Error, "Mixin.Observable.addSubscription: options invalid");
+ return observable.publishSubscription('Hello', observable);
+ }), Error, "Mixin.Observable.publishSubscription: options invalid");
raises((function() {
- return observable.addSubscription('Hello', Observerable);
- }), Error, "Mixin.Observable.addSubscription: options invalid");
+ return observable.publishSubscription('Hello', Observerable);
+ }), Error, "Mixin.Observable.publishSubscription: options invalid");
observable = new Observerable();
raises((function() {
return observable.subscribers('Hello');
@@ -239,7 +239,7 @@ $(document).ready(function() {
raises((function() {
return observable.addSubscriber(subscriber, ['Hello']);
}), Error, "Mixin.Observable.subscribe: Hello does not exist for subscription_name");
- observable.addSubscription('Hello');
+ observable.publishSubscription('Hello');
raises((function() {
return observable.addSubscriber(subscriber, ['Hello', (function() {})], 'Goodbye');
}), Error, "Mixin.Observable.subscribe: Goodbye does not exist for subscription_name");
@@ -385,7 +385,7 @@ $(document).ready(function() {
raises((function() {
return observable.removeSubscribers(Observerable);
}), Error, "Mixin.Observable.removeSubscribers: subscription_name invalid");
- observable.addSubscription('Hello');
+ observable.publishSubscription('Hello');
observable.removeSubscribers('Hello');
raises((function() {
return observable.removeSubscribers('Hello', 0);
@@ -126,16 +126,16 @@ $(document).ready( ->
raises((->observable.hasSubscription(Observerable)), Error, "Mixin.Observable.hasSubscription: subscription_name invalid")
observable = new Observerable()
- raises((->observable.addSubscription()), Error, "Mixin.Observable.addSubscription: subscription_name missing")
- raises((->observable.addSubscription(0)), Error, "Mixin.Observable.addSubscription: subscription_name invalid")
- raises((->observable.addSubscription({})), Error, "Mixin.Observable.addSubscription: subscription_name invalid")
- raises((->observable.addSubscription([])), Error, "Mixin.Observable.addSubscription: subscription_name invalid")
- raises((->observable.addSubscription(observable)), Error, "Mixin.Observable.addSubscription: subscription_name invalid")
- raises((->observable.addSubscription(Observerable)), Error, "Mixin.Observable.addSubscription: subscription_name invalid")
- raises((->observable.addSubscription('Hello', 42)), Error, "Mixin.Observable.addSubscription: options invalid")
- raises((->observable.addSubscription('Hello', [])), Error, "Mixin.Observable.addSubscription: options invalid")
- raises((->observable.addSubscription('Hello', observable)), Error, "Mixin.Observable.addSubscription: options invalid")
- raises((->observable.addSubscription('Hello', Observerable)), Error, "Mixin.Observable.addSubscription: options invalid")
+ raises((->observable.publishSubscription()), Error, "Mixin.Observable.publishSubscription: subscription_name missing")
+ raises((->observable.publishSubscription(0)), Error, "Mixin.Observable.publishSubscription: subscription_name invalid")
+ raises((->observable.publishSubscription({})), Error, "Mixin.Observable.publishSubscription: subscription_name invalid")
+ raises((->observable.publishSubscription([])), Error, "Mixin.Observable.publishSubscription: subscription_name invalid")
+ raises((->observable.publishSubscription(observable)), Error, "Mixin.Observable.publishSubscription: subscription_name invalid")
+ raises((->observable.publishSubscription(Observerable)), Error, "Mixin.Observable.publishSubscription: subscription_name invalid")
+ raises((->observable.publishSubscription('Hello', 42)), Error, "Mixin.Observable.publishSubscription: options invalid")
+ raises((->observable.publishSubscription('Hello', [])), Error, "Mixin.Observable.publishSubscription: options invalid")
+ raises((->observable.publishSubscription('Hello', observable)), Error, "Mixin.Observable.publishSubscription: options invalid")
+ raises((->observable.publishSubscription('Hello', Observerable)), Error, "Mixin.Observable.publishSubscription: options invalid")
observable = new Observerable()
raises((->observable.subscribers('Hello')), Error, "Mixin.Observable.subscribers: subscriber 'Observerable' does not recognize 'Hello'")
@@ -156,7 +156,7 @@ $(document).ready( ->
subscriber = new Subscriber()
raises((->observable.addSubscriber(subscriber, 'Hello')), Error, "Mixin.Observable.subscribe: Hello does not exist for subscription_name")
raises((->observable.addSubscriber(subscriber, ['Hello'])), Error, "Mixin.Observable.subscribe: Hello does not exist for subscription_name")
- observable.addSubscription('Hello')
+ observable.publishSubscription('Hello')
raises((->observable.addSubscriber(subscriber, ['Hello', (->)], 'Goodbye')), Error, "Mixin.Observable.subscribe: Goodbye does not exist for subscription_name")
raises((->observable.addSubscriber(subscriber, ['Hello', (->)], ['Goodbye'])), Error, "Mixin.Observable.subscribe: Goodbye does not exist for subscription_name")
raises((->observable.addSubscriber(subscriber, ['Hello', (->)], ['Good day', 'sir!'])), Error, "Mixin.Observable.subscribe: Goodbye does not exist for subscription_name")
@@ -210,7 +210,7 @@ $(document).ready( ->
raises((->observable.removeSubscribers([])), Error, "Mixin.Observable.removeSubscribers: subscription_name invalid")
raises((->observable.removeSubscribers(observable)), Error, "Mixin.Observable.removeSubscribers: subscription_name invalid")
raises((->observable.removeSubscribers(Observerable)), Error, "Mixin.Observable.removeSubscribers: subscription_name invalid")
- observable.addSubscription('Hello'); observable.removeSubscribers('Hello')
+ observable.publishSubscription('Hello'); observable.removeSubscribers('Hello')
raises((->observable.removeSubscribers('Hello', 0)), Error, "Mixin.Observable.removeSubscribers: test_fn invalid")
raises((->observable.removeSubscribers('Hello', {})), Error, "Mixin.Observable.removeSubscribers: test_fn invalid")
raises((->observable.removeSubscribers('Hello', [])), Error, "Mixin.Observable.removeSubscribers: test_fn invalid")

0 comments on commit 3c80bc3

Please sign in to comment.