Skip to content

Instantly share code, notes, and snippets.

@muizidn
Created October 6, 2018 09:53
Show Gist options
  • Save muizidn/00e50742c4d0226b797c66324b7ec282 to your computer and use it in GitHub Desktop.
Save muizidn/00e50742c4d0226b797c66324b7ec282 to your computer and use it in GitHub Desktop.
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