refactor(pipes): use angular lifecycle hooks instead of PipeOnDestroy

BREAKING CHANGE:
Previously, pipes that wanted to be notified when they were destroyed
would implement the PipeOnDestroy interface and name the callback
`onDestroy`. This change removes the PipeOnDestroy interface and
instead uses Angular's lifecycle interface `OnDestroy`, with the
`ngOnDestroy` method.

Before:
```
import {Pipe, PipeOnDestroy} from 'angular2/angular2';
@Pipe({pure: false})
export class MyPipe implements PipeOnDestroy {
  onDestroy() {}
}
```

After:
import {Pipe, OnDestroy} from 'angular2/angular2';
@Pipe({pure: false})
export class MyPipe implements PipeOnDestroy {
  ngOnDestroy() {}
}
This commit is contained in:
Jeff Cross
2015-11-17 10:09:23 -08:00
committed by vsavkin
parent 604c8bbad5
commit fcc7ce225e
13 changed files with 79 additions and 82 deletions
@@ -4,7 +4,7 @@ import {
Pipe,
Injectable,
ChangeDetectorRef,
PipeOnDestroy,
OnDestroy,
PipeTransform,
WrappedValue
} from 'angular2/core';
@@ -55,7 +55,7 @@ var _observableStrategy = new ObservableStrategy();
*/
@Pipe({name: 'async', pure: false})
@Injectable()
export class AsyncPipe implements PipeTransform, PipeOnDestroy {
export class AsyncPipe implements PipeTransform, OnDestroy {
/** @internal */
_latestValue: Object = null;
/** @internal */
@@ -70,7 +70,7 @@ export class AsyncPipe implements PipeTransform, PipeOnDestroy {
public _ref: ChangeDetectorRef;
constructor(_ref: ChangeDetectorRef) { this._ref = _ref; }
onDestroy(): void {
ngOnDestroy(): void {
if (isPresent(this._subscription)) {
this._dispose();
}