{% if book.isPdf %}
{% else %}
{% endif %}
This method creates a new Observable sequence from an array-like or iterable object.
iterable
(Array
|Arguments
|Iterable
): An array-like or iterable object to convert to an Observable sequence.[mapFn]
(Function
): Map function to call on every element of the array.[thisArg]
(Any
): The context to use calling the mapFn if provided.[scheduler=Rx.Scheduler.currentThread]
(Scheduler
): Scheduler to run the enumeration of the input sequence on.
(Observable
): The observable sequence whose elements are pulled from the given iterable sequence.
{% if book.isPdf %}
function f() {
return Rx.Observable.from(arguments);
}
f(1, 2, 3).subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: 1
// => onNext: 2
// => onNext: 3
// => onCompleted
var s = new Set(["foo", window]);
Rx.Observable.from(s).subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: foo
// => onNext: window
// => onCompleted
var m = new Map([[1, 2], [2, 4], [4, 8]]);
Rx.Observable.from(m).subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: [1, 2]
// => onNext: [2, 4]
// => onNext: [4, 8]
// => onCompleted
Rx.Observable.from("foo").subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: f
// => onNext: o
// => onNext: o
// => onCompleted
Rx.Observable.from([1, 2, 3], x => x + x).subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: 2
// => onNext: 4
// => onNext: 6
// => onCompleted
Rx.Observable.from({length: 5}, (v, k) => k).subscribe(
x => console.log(`onNext: ${x}`),
e => console.log(`onError: ${e}`),
() => console.log('onCompleted'));
// => onNext: 0
// => onNext: 1
// => onNext: 2
// => onNext: 3
// => onNext: 4
// => onCompleted
{% else %}
{% endif %}