Skip to content

Instantly share code, notes, and snippets.

@RPallas92
Last active January 3, 2018 17:56
Show Gist options
  • Save RPallas92/06180e09b7f796d3fec2fb60be4aea6e to your computer and use it in GitHub Desktop.
Save RPallas92/06180e09b7f796d3fec2fb60be4aea6e to your computer and use it in GitHub Desktop.
protocol BaseContext {
var cloudKitApiKey: String {get}
var todosDataSource: TodosDataSource {get}
}
class AppContext: BaseContext {
var cloudKitApiKey = "sjsfAJ&76sdgjhs3434JHS3"
var todosDataSource: TodosDataSource = TodosCloudKitDataSource()
}
class TodosListContext: AppContext {
let view: TodosListView
init(view: TodosListView) { self.view = view }
}
func deleteAllTodosFromDataSource() -> AsyncResult<TodosListContext, Event, GenericError> {
return AsyncResult<TodosListContext, Event, GenericError>.ask.flatMap { context in
context.todosDataSource.deleteAllTodos()
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment