From 1f0c1b02c5708554efc618e53a13f1c2af2a526f Mon Sep 17 00:00:00 2001 From: nghialv Date: Thu, 4 Jun 2015 23:56:38 +0900 Subject: [PATCH] edit example --- DemoApp/DemoApp/ViewController.swift | 11 ++++++++--- README.md | 13 +++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/DemoApp/DemoApp/ViewController.swift b/DemoApp/DemoApp/ViewController.swift index ab32027..21d21b6 100644 --- a/DemoApp/DemoApp/ViewController.swift +++ b/DemoApp/DemoApp/ViewController.swift @@ -14,9 +14,14 @@ class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() - let f = searchRepositories("Hakuba") <^> { $0[0].ownerName } >>- requestUser - f.onSuccess { result in - println(result) + let e = NSError(domain: "noSuchElement", code: 1, userInfo: nil) + + let f = searchRepositories("Hakuba").filter(e){ $0.count > 0 } <^> { $0.first!.ownerName } >>- requestUser + f.onComplete { result in + switch result { + case .Success(let user): println(user) + case .Failure(let error): println(error) + } } } } diff --git a/README.md b/README.md index 85f679e..a6400a6 100644 --- a/README.md +++ b/README.md @@ -78,6 +78,19 @@ Usage - `map` `<^>` - `flatMap` `>>-` - `filter` + +``` swift +let e = NSError(domain: "noSuchElement", code: 1, userInfo: nil) + +let f = searchRepositories("Hakuba").filter(e){ $0.count > 0 } <^> { $0.first!.ownerName } >>- requestUser +f.onComplete { result in + switch result { + case .Success(let user): println(user) + case .Failure(let error): println(error) + } +} +``` + - `andThen` - `recover` - `zip`