Skip to content

Commit

Permalink
update Readme
Browse files Browse the repository at this point in the history
  • Loading branch information
nghialv committed Jun 4, 2015
1 parent 462f4a7 commit af105e7
Showing 1 changed file with 44 additions and 0 deletions.
44 changes: 44 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,29 @@ Usage
-----

- `map` `<^>`

```swift
let f = requestUser("nghialv") <^> { $0.id }

f.onSuccess { userId in
println(userId)
}

```

- `flatMap` `>>-`

```swift
let f = searchRepositories("Hakuba") <^> { $0.first!.ownerName } >>- requestUser

f.onComplete { result in
switch result {
case .Success(let user): println(user)
case .Failure(let error): println(error)
}
}
```

- `filter`

``` swift
Expand All @@ -94,6 +116,28 @@ f.onComplete { result in
```

- `andThen`

```swift
// side-effect
var reposCount = 0

let f1 = searchRepositories("Hakuba")
let f2 = f1.andThen { result in
switch result {
case .Success(let repos): reposCount = repos.value.count
case .Failure(let error): break
}
}
let f3 = f2 <^> { $0.first!.ownerName } >>- requestUser

f3.onComplete { result in
switch result {
case .Success(let user): println(user)
case .Failure(let error): println(error)
}
}
```

- `recover`
- `zip`
- `flatten`
Expand Down

0 comments on commit af105e7

Please sign in to comment.