Little refactorings

This commit is contained in:
dankito 2020-07-14 17:46:37 +02:00
parent 051fc9a3e9
commit a101a37db2
1 changed files with 8 additions and 12 deletions

View File

@ -1,14 +1,10 @@
import net.dankito.banking.fints.FinTsClient
import net.dankito.banking.fints.callback.FinTsClientCallback
import net.dankito.banking.fints.model.AccountData
import net.dankito.banking.fints.model.AccountFeature
import net.dankito.banking.fints.model.BankData
import net.dankito.banking.fints.model.CustomerData
import net.dankito.banking.fints.model.*
import net.dankito.banking.fints.response.client.AddAccountResponse
import net.dankito.banking.fints.response.client.FinTsClientResponse
import net.dankito.banking.fints.response.client.GetTransactionsResponse
import net.dankito.banking.fints.webclient.IWebClient
import net.dankito.utils.multiplatform.toDate
import kotlin.native.concurrent.TransferMode
import kotlin.native.concurrent.Worker
import kotlin.native.concurrent.freeze
@ -31,14 +27,15 @@ open class FinTsClientForCustomerSwift(
protected val callback: FinTsClientCallback
) {
protected val worker = Worker.start(name = "FinTsClient worker for $customer")
init {
webClient.freeze()
callback.freeze()
}
protected val worker = Worker.start(name = "FinTsClient worker for $customer")
open fun addAccountAsync(callback: (AddAccountResponse) -> Unit) {
val future = worker.execute(TransferMode.SAFE, { createWorkerArgument() }) { arg ->
@ -61,12 +58,11 @@ open class FinTsClientForCustomerSwift(
FinTsClientWorkerResult(bank.freeze(), customer.freeze(), response.freeze())
}
future.consume { result ->
map(bank, result.bank)
map(customer, result.customer)
val result = future.result
map(bank, result.bank)
map(customer, result.customer)
callback(result.response)
}
callback(result.response)
}