mirror of
https://github.com/fooflington/selfdefined.git
synced 2025-06-13 05:55:26 +00:00
update
This commit is contained in:
53
node_modules/rxjs/_esm2015/operators/mapTo.js
generated
vendored
Normal file
53
node_modules/rxjs/_esm2015/operators/mapTo.js
generated
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
import { Subscriber } from '../Subscriber';
|
||||
/**
|
||||
* 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(value) {
|
||||
return (source) => source.lift(new MapToOperator(value));
|
||||
}
|
||||
class MapToOperator {
|
||||
constructor(value) {
|
||||
this.value = value;
|
||||
}
|
||||
call(subscriber, source) {
|
||||
return source.subscribe(new MapToSubscriber(subscriber, this.value));
|
||||
}
|
||||
}
|
||||
/**
|
||||
* We need this JSDoc comment for affecting ESDoc.
|
||||
* @ignore
|
||||
* @extends {Ignored}
|
||||
*/
|
||||
class MapToSubscriber extends Subscriber {
|
||||
constructor(destination, value) {
|
||||
super(destination);
|
||||
this.value = value;
|
||||
}
|
||||
_next(x) {
|
||||
this.destination.next(this.value);
|
||||
}
|
||||
}
|
||||
//# sourceMappingURL=mapTo.js.map
|
Reference in New Issue
Block a user