Created
October 6, 2018 09:53
-
-
Save muizidn/00e50742c4d0226b797c66324b7ec282 to your computer and use it in GitHub Desktop.
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
class WhateverUseCase { | |
... | |
let store: Store // I don't need specify any type | |
func performOperation() { | |
/// Car | |
store.fetch(Car.self, with: [.color(.red), .year(Date())]) | |
.success { cars in | |
// Do logic | |
} | |
.error { error in | |
// Propagate | |
} | |
let mazda = Mazda(color: .red, year: "2017".toDate()!) | |
store.save(mazda) | |
.success { print("Yay") } | |
.error { print($0) } | |
store.delete(mazda) | |
.success { print("Yay") } | |
.error { print($0) } | |
/// Person | |
store.fetch(Person.self, with: [.eye(.blue), .firstName("Muiz")]) | |
.success { persons in | |
// Do logic | |
} | |
.error { error in | |
// Propagate | |
} | |
let muiz = Person(eye: .blue, firstName: "Muiz") | |
store.save(muiz) | |
.success { print("Yay") } | |
.error { print($0) } | |
store.delete(muiz) | |
.success { print("Yay") } | |
.error { print($0) } | |
} | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment