Skip to content
This repository has been archived by the owner on Apr 20, 2018. It is now read-only.

Latest commit

 

History

History
89 lines (73 loc) · 2.74 KB

dooncompleted.md

File metadata and controls

89 lines (73 loc) · 2.74 KB

Rx.Observable.prototype.doOnCompleted(onCompleted, [thisArg])

Rx.Observable.prototype.tapOnCompleted(onCompleted, [thisArg])

Invokes an action upon graceful termination of the observable sequence.

This method can be used for debugging, logging, etc. of query behavior by intercepting the message stream to run arbitrary actions for messages on the pipeline.

Arguments

  1. oncompleted (Function): Function to invoke upon graceful termination of the observable sequence.
  2. [thisArg] (Any): Object to use as this when executing callback.

Returns

(Observable): The source sequence with the side-effecting behavior applied.

Example

/* Using a function */
var source = Rx.Observable.range(0, 3)
  .doOnCompleted(
    function () { console.log('Do Completed'); }
  );

var subscription = source.subscribe(
  function (x) {
    console.log('Next: %s', x);
  },
  function (err) {
    console.log('Error: %s', err);
  },
  function () {
    console.log('Completed');
  });

// => Next: 0
// => Next: 1
// => Next: 2
// => Do Completed
// => Completed

/* Using a thisArg */

var source = Rx.Observable.range(0, 3)
  .doOnCompleted(
    function () { this.log('Do Completed'); },
    console
  );

var subscription = source.subscribe(
  function (x) {
    console.log('Next: %s', x);
  },
  function (err) {
    console.log('Error: %s', err);
  },
  function () {
    console.log('Completed');
  });

// => Next: 0
// => Next: 1
// => Next: 2
// => Do Completed
// => Completed

Location

File:

Dist:

NPM Packages:

NuGet Packages:

Unit Tests: