Last active
October 23, 2017 11:50
-
-
Save ahernandezlopez/0bc1af4398b231f91ef8db82a57652e6 to your computer and use it in GitHub Desktop.
Example of implementation of Domain Events in Swift. The snippet illustrates Domain Events in a Service with RxSwift
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
| protocol ListingService: class { | |
| var events: Observable<ListingServiceEvent> { get } | |
| func filteredEvents(listing: Listing) -> Observable<ListingServiceEvent> | |
| func create(params: ListingServiceCreateParams, | |
| completion: ((Result<Listing, ListingServiceCreateError>) -> ())?) | |
| func update(listing: Listing, | |
| params: ListingServiceUpdateParams, | |
| completion: ((Result<Listing, ListingServiceUpdateError>) -> ())?) | |
| func delete(listing: Listing, | |
| completion: ((Result<Listing, ListingServiceDeleteError>) -> ())?) | |
| } | |
| enum ListingServiceEvent { | |
| case create(listing: Listing) | |
| case update(listing: Listing) | |
| case delete(listing: Listing) | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment