Repositoryはデータ通信を行うもので、
主にAPIを叩いたり、ローカルのDBにアクセスするときに使用しています。
戻り値がVoidになっておりますが、
データを取得したらここに戻り値にそれをセットします。
あくまで、データをCreate(生成)、Read(読み取り)、Update(更新)、Delete(削除)のが責務にさせることがポイントです。
import UIKit
import RxCocoa
import RxSwift
protocol AuthRepositoryInjectable {
var authRepositoryImpl: AuthRepository { get }
}
extension AuthRepositoryInjectable {
var authRepositoryImpl: AuthRepository {
return AuthRepositoryImpl.shared
}
}
protocol AuthRepository {
func doSomething() -> Single<Element>
}
class AuthRepositoryImpl: AuthRepository {
let bag = DisposeBag()
static var shared = AuthRepositoryImpl()
private init() {}
func doSomething() -> Single<Void> {
return Single<Void>.just(())
}
}