1func transformUsingMap() -> Observable<String> {
2 return Observable.of(1, 2, 3)
3 .map { String("\($0)") }
4}
5
6func arrayToNewObject(items: [Item]) -> [Data] {
7 return items.map({ item in
8 return Data(item)
9 })
10}
1// RxJS v6+
2import { from } from 'rxjs';
3import { map } from 'rxjs/operators';
4
5//emit (1,2,3,4,5)
6const source = from([1, 2, 3, 4, 5]);
7//add 10 to each value
8const example = source.pipe(map(val => val + 10));
9//output: 11,12,13,14,15
10const subscribe = example.subscribe(val => console.log(val));