Sha256: a1f0c210ad819147f7b7f98ffefa8b1b715a71201af385eb4f8ceb98ed8eb455

Contents?: true

Size: 1.17 KB

Versions: 49

Compression:

Stored size: 1.17 KB

Contents

import { Observable } from '../Observable';
import { mapTo as higherOrder } from '../operators/mapTo';

/**
 * Emits the given constant value on the output Observable every time the source
 * Observable emits a value.
 *
 * <span class="informal">Like {@link map}, but it maps every source value to
 * the same output value every time.</span>
 *
 * <img src="./img/mapTo.png" width="100%">
 *
 * Takes a constant `value` as argument, and emits that whenever the source
 * Observable emits a value. In other words, ignores the actual source value,
 * and simply uses the emission moment to know when to emit the given `value`.
 *
 * @example <caption>Map every click to the string 'Hi'</caption>
 * var clicks = Rx.Observable.fromEvent(document, 'click');
 * var greetings = clicks.mapTo('Hi');
 * greetings.subscribe(x => console.log(x));
 *
 * @see {@link map}
 *
 * @param {any} value The value to map each source value to.
 * @return {Observable} An Observable that emits the given `value` every time
 * the source Observable emits something.
 * @method mapTo
 * @owner Observable
 */
export function mapTo<T, R>(this: Observable<T>, value: R): Observable<R> {
  return higherOrder(value)(this);
}

Version data entries

49 entries across 49 versions & 4 rubygems

Version Path
govuk_publishing_components-17.8.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.7.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.6.1 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.6.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.5.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.4.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.3.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.2.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.1.1 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.1.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-17.0.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.29.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.28.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.27.1 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.27.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.26.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.25.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.24.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.23.0 node_modules/rxjs/src/operator/mapTo.ts
govuk_publishing_components-16.22.0 node_modules/rxjs/src/operator/mapTo.ts