Skip to content

Instantly share code, notes, and snippets.

@RuiAAPeres
Created January 8, 2016 10:25
Show Gist options
  • Save RuiAAPeres/ea2d752dbeb4f30c0e86 to your computer and use it in GitHub Desktop.
Save RuiAAPeres/ea2d752dbeb4f30c0e86 to your computer and use it in GitHub Desktop.
func fetchData(request: NSURLRequest) -> SignalProducer<[Foo], Error> {
return foosFromServer(request).flatMapError {_ in //network failed deal with it}
.flatMapLatest { parseFoos($0).flatMapError {_ in //parse failed deal with it} }
.flatMapLatest { persistFoos($0).flatMapError {_ in //persist failed deal with it} }
.flatMapError { error in loadFoosFromCache().mapError {_ in error} }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment