
p.location-badge.
  exported from <a href='../core'>angular2/core</a>
  defined in <a href="https://github.com/angular/angular/tree/2.0.0-alpha.37/modules/angular2/src/core/change_detection/pipe_transform.ts#L33-L84">angular2/src/core/change_detection/pipe_transform.ts (line 33)</a>

:markdown
  To create a stateful Pipe, you should implement this interface.
  
  A stateful pipe may produce different output, given the same input. It is
  likely that a stateful pipe may contain state that should be cleaned up when
  a binding is destroyed. For example, a subscription to a stream of data may need to
  be disposed, or an interval may need to be cleared.
  
  ### Example ([live demo](http://plnkr.co/edit/hlaejwQAmWayxwc5YXQE?p=preview))
  
  In this example, a pipe is created to countdown its input value, updating it every
  50ms. Because it maintains an internal interval, it automatically clears
  the interval when the binding is destroyed or the countdown completes.
  
  ```
  import {Pipe, PipeTransform} from 'angular2/angular2'
  @Pipe({name: 'countdown'})
  class CountDown implements PipeTransform, PipeOnDestroy {
    remainingTime:Number;
    interval:SetInterval;
    onDestroy() {
      if (this.interval) {
        clearInterval(this.interval);
      }
    }
    transform(value: any, args: any[] = []) {
      if (!parseInt(value, 10)) return null;
      if (typeof this.remainingTime !== 'number') {
        this.remainingTime = parseInt(value, 10);
      }
      if (!this.interval) {
        this.interval = setInterval(() => {
          this.remainingTime-=50;
          if (this.remainingTime <= 0) {
            this.remainingTime = 0;
            clearInterval(this.interval);
            delete this.interval;
          }
        }, 50);
      }
      return this.remainingTime;
    }
  }
  ```
  
  Invoking `{{ 10000 | countdown }}` would cause the value to be decremented by 50,
  every 50ms, until it reaches 0.
  
  
.l-main-section
  h2 Members
  .l-sub-section
    h3#onDestroy onDestroy

    
    pre.prettyprint
      code.
        onDestroy()
    
    :markdown




