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:
@@ -54,7 +54,8 @@ import {
|
||||
Inject,
|
||||
Host,
|
||||
SkipSelf,
|
||||
SkipSelfMetadata
|
||||
SkipSelfMetadata,
|
||||
OnDestroy
|
||||
} from 'angular2/core';
|
||||
|
||||
import {NgIf, NgFor} from 'angular2/common';
|
||||
@@ -1999,8 +2000,8 @@ class SomeViewport {
|
||||
}
|
||||
|
||||
@Pipe({name: 'double'})
|
||||
class DoublePipe implements PipeTransform {
|
||||
onDestroy() {}
|
||||
class DoublePipe implements PipeTransform, OnDestroy {
|
||||
ngOnDestroy() {}
|
||||
transform(value, args = null) { return `${value}${value}`; }
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user