Skip to content

Commit

Permalink
refactor(Subscription): allow Subscription to add Subscription<any>
Browse files Browse the repository at this point in the history
Allow the Subscription to add a child Subscription parameterized by <any>, not by <T>. There isn't a
clear reason why all child Subscriptions should be type <T>, and there are cases where we need to
have a <any> child.
  • Loading branch information
staltz authored and benlesh committed Dec 14, 2015
1 parent abb6ef0 commit 997a501
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions src/Subscriber.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ export class Subscriber<T> extends Subscription<T> implements Observer<T> {
}
}

add(sub: Subscription<T> | Function | void): void {
add(sub: Subscription<any> | Function | void): void {
// route add to the shared Subscription if it exists
const _subscription = this._subscription;
if (_subscription) {
Expand All @@ -68,7 +68,7 @@ export class Subscriber<T> extends Subscription<T> implements Observer<T> {
}
}

remove(sub: Subscription<T>): void {
remove(sub: Subscription<any>): void {
// route remove to the shared Subscription if it exists
if (this._subscription) {
this._subscription.remove(sub);
Expand Down
6 changes: 3 additions & 3 deletions src/Subscription.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ export class Subscription<T> {
}
}

add(subscription: Subscription<T>|Function|void): void {
add(subscription: Subscription<any>|Function|void): void {
// return early if:
// 1. the subscription is null
// 2. we're attempting to add our this
Expand All @@ -58,7 +58,7 @@ export class Subscription<T> {
return;
}

let sub = (<Subscription<T>> subscription);
let sub = (<Subscription<any>> subscription);

switch (typeof subscription) {
case 'function':
Expand All @@ -78,7 +78,7 @@ export class Subscription<T> {
}
}

remove(subscription: Subscription<T>): void {
remove(subscription: Subscription<any>): void {

// return early if:
// 1. the subscription is null
Expand Down

0 comments on commit 997a501

Please sign in to comment.