Skip to content

Instantly share code, notes, and snippets.

@atanasovdejan
Last active July 30, 2018 09:48
Show Gist options
  • Save atanasovdejan/a0142a402f134d76fa42e90efbdc853d to your computer and use it in GitHub Desktop.
Save atanasovdejan/a0142a402f134d76fa42e90efbdc853d to your computer and use it in GitHub Desktop.
import UIKit
protocol TestBusinessLogic
{
func fetchItems(request: Test.Fetch.Request)
}
protocol TestDataStore
{
//var name: String { get set }
}
class TestInteractor: TestBusinessLogic, TestDataStore
{
var presenter: TestPresentationLogic?
var worker: TestWorker?
//var name: String = ""
func fetchItems(request: Test.Fetch.Request) {
if request.itemId == nil || request.count == nil || request.keyword == nil {
return self.presenter?.presentFetchResults(response: Test.Fetch.Response(object: nil,isError: true, message: "Fields may not be empty."))
}
worker = TestWorker()
worker?.fetch(name: request.name, type: request.type, count: request.count, success: { (object) in
self.presenter?.presentFetchResults(response: Test.Fetch.Response(object: object, isError: false, message: nil))
}) { (error, message) in
self.presenter?.presentFetchResults(response: Test.Fetch.Response(object: nil, isError: true, message: message))
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment