Created
November 1, 2017 15:33
-
-
Save soxjke/48ea12c5f7b0a2eae69e5f4c78eb13bc to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
enum TestError: Swift.Error { | |
case uploadFailed | |
} | |
class Album { | |
let pages: [Page] = [] | |
} | |
class Page {} | |
class UploadServiceImpl { | |
private(set) lazy var addAction = Action<Album, Void, TestError>(execute:self.addActionBlock) | |
private lazy var pageAction = Action<Page, Void, TestError>(execute:self.pageActionBlock) | |
private lazy var completeAction = Action<Album, Void, TestError>(execute:self.completeActionBlock) | |
private func addActionBlock(input: Album) -> SignalProducer<Void, TestError> { | |
return SignalProducer<Page, TestError>(input.pages) | |
.flatMap(.concat) { pageAction.apply($0) } | |
.flatMap(.latest) { completeAction.apply(input) } | |
} | |
private func pageActionBlock(input: Page) -> SignalProducer<Void, TestError> { | |
return SignalProducer.empty | |
} | |
private func completeActionBlock(input: Album) -> SignalProducer<Void, TestError> { | |
return SignalProducer.empty | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment