Created
August 10, 2017 16:11
-
-
Save ncreated/87ed8e38bf447fad09c8def068af6f74 to your computer and use it in GitHub Desktop.
Medium blogpost snippet
This file contains hidden or 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
| func manage(change: Observable<Bool>) -> (value: Driver<ToggleValue>, isBusy: Driver<Bool>) { | |
| // ... | |
| let storage = self.storage | |
| let valueAfterSaving = change | |
| .flatMap { valueToSave -> Observable<ToggleValue> in | |
| storage | |
| .save(value: valueToSave) | |
| .map { ToggleValue.updated(valueToSave) } | |
| .catchErrorJustReturn(ToggleValue.fallback(!valueToSave)) | |
| } | |
| // ... | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment