You can do this by wrapping the method responsible for the API call.
In the following, the method responsible for API calls is APIClient.fetch
.
python
func fetchData(from caller: <API caller information>) {
APIClient.fetch { result in
//Handle using caller information caller and call result result
}
}
You can do the same if you are using RxSwift.
python
func fetchData(from caller: <API caller information>) {
APIClient.fetch
.subscribe(onNext: { result in
//Handle using caller information caller and call result result
})
}
Recommended Posts