-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #154 from RxSwiftCommunity/feature/mapMany
mapMany Operator
- Loading branch information
Showing
11 changed files
with
183 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,7 +3,8 @@ Changelog | |
|
||
master | ||
----- | ||
|
||
- added `mapMany` operator | ||
- added `toSortedArray` operator | ||
|
||
3.3.0 | ||
----- | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
github "ReactiveX/RxSwift" "4.1.2" | ||
github "ReactiveX/RxSwift" "4.2.0" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
Playground/RxSwiftExtPlayground.playground/Pages/mapMany.xcplaygroundpage/Contents.swift
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/*: | ||
> # IMPORTANT: To use `RxSwiftExtPlayground.playground`, please: | ||
|
||
1. Make sure you have [Carthage](https://github.com/Carthage/Carthage) installed | ||
1. Fetch Carthage dependencies from shell: `carthage bootstrap --platform ios` | ||
1. Build scheme `RxSwiftExtPlayground` scheme for a simulator target | ||
1. Choose `View > Show Debug Area` | ||
*/ | ||
|
||
//: [Previous](@previous) | ||
import RxSwift | ||
import RxSwiftExt | ||
|
||
example("mapMany") { | ||
let numbers = Observable.of(1...10) | ||
let strings = Observable.of(["RxSwift", "is" ,"awesome", "along", "with", "RxSwiftCommunity"]) | ||
|
||
// Map many using a model initializer | ||
numbers.mapMany(SomeModel.init) | ||
.subscribe(onNext: { result in | ||
print(result) | ||
}) | ||
|
||
// Map many with a transformation closure | ||
numbers.mapMany { $0 * $0 } | ||
.subscribe(onNext: { result in | ||
print(result) | ||
}) | ||
|
||
strings.mapMany { $0.lowercased() } | ||
.subscribe(onNext: { result in | ||
print(result) | ||
}) | ||
|
||
struct SomeModel: CustomStringConvertible { | ||
let number: Int | ||
var description: String { return "#\(number)" } | ||
|
||
init(_ number: Int) { | ||
self.number = number | ||
} | ||
} | ||
} | ||
|
||
//: [Next](@next) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.