lehakorshun
02/14/2020, 3:15 PMArkadii Ivanov
02/14/2020, 3:32 PMclass SharedDataSource {
fun load(): SingleWrapper<String> =
singleFromFunction {
// A long running operation
"A result"
}
.subscribeOn(ioScheduler)
.observeOn(mainScheduler)
.wrap()
}
After that you will be able to subscribe like this:
let dataSource = SharedDataSource()
let disposable = dataSource
.load()
.subscribe(isThreadLocal: false, onSubscribe: nil, onError: nil) { (value: NSString) in print(value) }
// At some point later
disposable.dispose()
But subscribe
is the only method available in the provided wrappers. If you need additional operators you can extend the wrapper with your custom class and add whatever you want there.lehakorshun
02/14/2020, 3:40 PMwrap
function, but I have a trouble with mutation state. thx for the response.lehakorshun
02/14/2020, 3:43 PMArkadii Ivanov
02/14/2020, 3:58 PM