Options
All
  • Public
  • Public/Protected
  • All
Menu

Class Subject<T>

Type parameters

  • T

Hierarchy

Index

Constructors

constructor

Methods

complete

  • complete(): void

error

  • error(e: any): void

next

  • next(x: T): void

pipe

subscribe

  • Subscribe to this observable

    example
    
    // Create a subscription
    const s = myObs.subscribe(x => {
     console.log(x);
    });
    
    s.unsubscribe(); // unsubscribe

    Type parameters

    Parameters

    • obs: O

      observer to subscribe to the observable

    Returns Subscription

Static create

  • Create a new observable

    example
    
    // Create an observable
    const myObs = Observable.create(observer => {
      let x = 0;
      const y = setInterval(() => {
        // that emits incrementing values
        observer.next(x++);
      }, 1000); // each second
      return function cleanup() {
        // and cleans up after its self
        clearInterval(y);
      }
    });

    Type parameters

    • T

      value type this observable emits

    Parameters

    Returns Observable<T>

Generated using TypeDoc