Skip to content

Commit 45a18a9

Browse files
committed
Documentation fixes.
1 parent 3c7d2af commit 45a18a9

File tree

10 files changed

+287
-93
lines changed

10 files changed

+287
-93
lines changed

Documentation/DesignRationale.md

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,10 +118,12 @@ observable
118118
>- disposeBag.addDisposable
119119
```
120120

121-
All of the Rx public interfaces don't depend at all on the `>-` operator.
121+
None of the Rx public interfaces depend on the >- operator.
122122

123123
It was actually introduced quite late and you can use Rx operators (map, filter ...) without it.
124124

125+
### Replacing `>-` with your own operator
126+
125127
If you dislike `>-` operator and want to use `|>` or `~>` operators, just define them in your project in this form:
126128

127129
```swift
@@ -134,7 +136,7 @@ public func |> <In, Out>(source: In, @noescape transform: In -> Out) -> Out {
134136

135137
or
136138

137-
```
139+
```swift
138140
infix operator ~> { associativity left precedence 91 }
139141

140142
public func ~> <In, Out>(source: In, @noescape transform: In -> Out) -> Out {
@@ -164,30 +166,28 @@ combineLatest(a, b) { $0 + $1 }
164166
~> subscribeNext { println($0) }
165167
```
166168

167-
So why was `>-` chosen in the end? Well, it was a difficult decision.
168-
169-
Why wasn't standard function application operator used?
169+
### Why wasn't standard function application operator used?
170170

171171
I've first tried to find a similar operator in swift core libraries, but couldn't find it. That meant that I'll need to define something myself or find some third party library that contains reference function application operator definition and use it.
172172
Otherwise all of the example code would be unreadable.
173173

174-
Why wasn't some standard library used for that operator?
174+
### Why wasn't some standard library used for that operator?
175175

176176
Well, I'm not sure there is a clear consensus in the community about funtion application operators or libraries that define them.
177177

178-
Why wasn't function application operator defined only for `Observables` and `Disposables`?
178+
### Why wasn't function application operator defined only for `Observables` and `Disposables`?
179179

180180
One of the solutions could have been to provide a specialized operator that just works for `Observables` and `Disposables`.
181181
In that case, if an identically named general purpose function application operator is defined somewhere else, there would still be collision, priority or ambiguity problems.
182182

183-
Why wasn't some more standard operator like `|>` or `~>` used?
183+
### Why wasn't some more standard operator like `|>` or `~>` used?
184184

185185
`|>` or `~>` are probably more commonly used operators in swift, so if there was another definition for them in Rx as general purpose function application operators, there is a high probability they would collide with definitions in other frameworks or project.
186186

187187
The simplest and safest solution IMHO was to create some new operator that made sense in this context and there is a low probability anyone else uses it.
188188
In case the operator naming choice was wrong, name is rare and community eventually reaches consensus on the matter, it's more easier to find and replace it in user projects.
189189

190-
I have experimented for a week with different operators and in the end these are the reasons why `>-` was chosen
190+
### Rationale why `>-` was chosen
191191

192192
* It's short, only two characters
193193
* It looks like a sink to the right, which is a function it actually performs, so it's intuitive.

Documentation/Examples.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ self.usernameOutlet.rx_text >- map { username in
159159
// provided.
160160
// That's what `switchLatest` does
161161
>- switchLatest
162-
// Not we need to bind that to the user interface somehow.
162+
// Now we need to bind that to the user interface somehow.
163163
// Good old `subscribeNext` can do that
164164
// That's the end of `Observable` chain.
165165
// This will produce a `Disposable` object that can unbind everything and cancel

0 commit comments

Comments
 (0)