Skip to content

Commit

Permalink
Merge pull request #154 from RxSwiftCommunity/feature/mapMany
Browse files Browse the repository at this point in the history
mapMany Operator
  • Loading branch information
jdisho authored Jul 8, 2018
2 parents 2204a68 + 093e765 commit 0ca281f
Show file tree
Hide file tree
Showing 11 changed files with 183 additions and 33 deletions.
8 changes: 4 additions & 4 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ jobs:
XCODE_TEST_REPORTS: /tmp/xcode-test-results
LANG: en_US.UTF-8
macos:
xcode: '9.2.0'
xcode: '9.4.0'
steps:
- checkout
- run: mkdir -p $CIRCLE_ARTIFACTS $CIRCLE_TEST_REPORTS $XCODE_TEST_REPORTS
Expand All @@ -32,13 +32,13 @@ jobs:
- Carthage
- run:
name: Test macOS
command: xcodebuild test -scheme RxSwiftExt-macOS -workspace RxSwiftExt.xcworkspace -sdk macosx -destination "arch=x86_64" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/macOS.html
command: set -o pipefail && xcodebuild test -scheme RxSwiftExt-macOS -workspace RxSwiftExt.xcworkspace -sdk macosx -destination "arch=x86_64" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/macOS.html
- run:
name: Test iOS
command: xcodebuild test -scheme RxSwiftExt-iOS -workspace RxSwiftExt.xcworkspace -sdk iphonesimulator -destination "name=iPhone X" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/iOS.html
command: set -o pipefail && xcodebuild test -scheme RxSwiftExt-iOS -workspace RxSwiftExt.xcworkspace -sdk iphonesimulator -destination "name=iPhone X" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/iOS.html
- run:
name: Test tvOS
command: xcodebuild test -scheme RxSwiftExt-tvOS -workspace RxSwiftExt.xcworkspace -sdk appletvsimulator -destination "name=Apple TV 4K (at 1080p)" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/tvOS.html
command: set -o pipefail && xcodebuild test -scheme RxSwiftExt-tvOS -workspace RxSwiftExt.xcworkspace -sdk appletvsimulator -destination "name=Apple TV 4K (at 1080p)" | xcpretty -c -r html --output $XCODE_TEST_REPORTS/tvOS.html
- store_artifacts:
path: /tmp/xcode-test-results
"RxSwiftExt Release":
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ Changelog

master
-----

- added `mapMany` operator
- added `toSortedArray` operator

3.3.0
-----
Expand Down
2 changes: 1 addition & 1 deletion Cartfile.resolved
Original file line number Diff line number Diff line change
@@ -1 +1 @@
github "ReactiveX/RxSwift" "4.1.2"
github "ReactiveX/RxSwift" "4.2.0"
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
- [ignore(Any...)](ignore) operator, filters out any of the elements passed in parameters
- [Observable.once(Element)](once) contructor, creates a sequence that delivers an element *once* to the first subscriber then completes. The same sequence will complete immediately without delivering any element to all further subscribers.
- [mapAt(KeyPath)](mapAt) operator transforms a sequence of elements where each element is mapped to its value at the provided key path
- [mapMany()](mapMany) operator, projects each element of an observable collection into a new form.
- [mapTo(Any)](mapTo) operator, takes a sequence of elements and returns a sequence of the same constant provided as a parameter
- [not()](not) operator, applies a the boolean not (!) to a `Bool`
- [and()](and) operator, combines Bool values from one or more sequences and emits a single `Bool` value.
Expand All @@ -41,6 +42,7 @@
- [filterMap()](filterMap) operator, filters out some values and maps the rest (replaces `filter` + `map` combo)
- [Observable.fromAsync()](fromAsync) constructor, translates an async function that returns data through a completionHandler in a function that returns data through an Observable
- [ofType()](ofType) operator, filters the elements of an observable sequence, if that is an instance of the supplied type.
- [toSortedArray()](mapMany) operator, converts an Observable into another Observable that emits the whole sequence as a single array sorted using the provided closure and then terminates.
- **UIViewPropertyAnimator** [animate()](UIViewPropertyAnimator.animate) operator, returns a Completable that completes as soon as the animation ends.
- **UIViewPropertyAnimator** [fractionComplete](UIViewPropertyAnimator.fractionComplete) binder, provides a reactive way to bind to `UIViewPropertyAnimator.fractionComplete`.
*/
Expand Down
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)
Original file line number Diff line number Diff line change
Expand Up @@ -18,27 +18,27 @@ import RxSwiftExt
*/

example("Ensure that only a sorted array is emitted") {
let sequenceStream = Observable.of(1...12)
let array = Observable.of([10, 9, 12, 8, 4, 1, 1, 8, 14])
let sequenceStream = Observable.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)
let array = Observable.of(10, 9, 12, 8, 4, 1, 1, 8, 14)

// Ascending order
array.toSortedArray()
.subscribe(onNext: { result in
print(result)
})

array.toSortedArray(<)
array.toSortedArray(ascending: true)
.subscribe(onNext: { result in
print(result)
})

// Descending order
sequenceStream.toSortedArray(>)
sequenceStream.toSortedArray(by: >)
.subscribe(onNext: { result in
print(result)
})

array.toSortedArray(>)
array.toSortedArray(ascending: false)
.subscribe(onNext: { result in
print(result)
})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<playground version='6.0' target-platform='ios' display-mode='raw' last-migration='0900'>
<playground version='6.0' target-platform='ios' display-mode='rendered' last-migration='0900'>
<pages>
<page name='Index'/>
<page name='apply'/>
Expand All @@ -21,10 +21,6 @@
<page name='and'/>
<page name='nwise'/>
<page name='zipWith'/>
<page name='toSortedArray'/>
<page name='ofType'/>
<page name='withUnretained'/>
<page name='UIViewPropertyAnimator.animate'/>
<page name='UIViewPropertyAnimator.fractionComplete'/>
</pages>
</playground>
Loading

0 comments on commit 0ca281f

Please sign in to comment.