Skip to content

Instantly share code, notes, and snippets.

@mazz mazz/snippet.swift
Created Sep 21, 2019

Embed
What would you like to do?
public func fetchCourses() -> Single<[MbyCourse]> {
return Single.create { [unowned self] single in
do {
var fetchCourses: [MbyCourse] = []
// let chapters: [Org]!
try self.dbPool.read { db in
fetchCourses = try MbyCourse.fetchAll(db)
}
single(.success(fetchCourses))
} catch {
print("error: \(error)")
single(.error(error))
}
return Disposables.create {}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.