Last change
on this file since 6c1585f was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.1 KB
|
Line | |
---|
1 | import { OperatorFunction } from '../types';
|
---|
2 | /**
|
---|
3 | * Emits the given constant value on the output Observable every time the source
|
---|
4 | * Observable emits a value.
|
---|
5 | *
|
---|
6 | * <span class="informal">Like {@link map}, but it maps every source value to
|
---|
7 | * the same output value every time.</span>
|
---|
8 | *
|
---|
9 | * ![](mapTo.png)
|
---|
10 | *
|
---|
11 | * Takes a constant `value` as argument, and emits that whenever the source
|
---|
12 | * Observable emits a value. In other words, ignores the actual source value,
|
---|
13 | * and simply uses the emission moment to know when to emit the given `value`.
|
---|
14 | *
|
---|
15 | * ## Example
|
---|
16 | * Map every click to the string 'Hi'
|
---|
17 | * ```ts
|
---|
18 | * import { fromEvent } from 'rxjs';
|
---|
19 | * import { mapTo } from 'rxjs/operators';
|
---|
20 | *
|
---|
21 | * const clicks = fromEvent(document, 'click');
|
---|
22 | * const greetings = clicks.pipe(mapTo('Hi'));
|
---|
23 | * greetings.subscribe(x => console.log(x));
|
---|
24 | * ```
|
---|
25 | *
|
---|
26 | * @see {@link map}
|
---|
27 | *
|
---|
28 | * @param {any} value The value to map each source value to.
|
---|
29 | * @return {Observable} An Observable that emits the given `value` every time
|
---|
30 | * the source Observable emits something.
|
---|
31 | * @method mapTo
|
---|
32 | * @owner Observable
|
---|
33 | */
|
---|
34 | export declare function mapTo<T, R>(value: R): OperatorFunction<T, R>;
|
---|
Note:
See
TracBrowser
for help on using the repository browser.