[SWIFT] I want to separate the handling of call results according to the API caller (call trigger)

manner

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

I want to separate the handling of call results according to the API caller (call trigger)
I want to output the day of the week
I want to var_dump the contents of the intent
I want to call a method of another class
I want to know the answer of the rock-paper-scissors app
I want to display the name of the poster of the comment
I want to be aware of the contents of variables!
I want to return the scroll position of UITableView!
[Rails] I want to display the link destination of link_to in a separate tab
I want to expand the clickable part of the link_to method
I want to change the log output settings of UtilLoggingJdbcLogger
I want to call a method and count the number
I want to use the Java 8 DateTime API slowly (now)
I want to narrow down the display of docker ps
[Ruby] I want to reverse the order of the hash table
I want to temporarily disable the swipe gesture of UIPageViewController
I want to understand the flow of Spring processing request parameters
The story of Collectors.groupingBy that I want to keep for posterity
I want to limit the input by narrowing the range of numbers
I want to control the default error message of Spring Boot
I want to change the value of Attribute in Selenium of Ruby
I was addicted to the API version min23 setting of registerTorchCallback
I want to display the number of orders for today using datetime.
I want to know the JSP of the open portlet when developing Liferay
[Ruby] I want to extract only the value of the hash and only the key
I want to pass the argument of Annotation and the argument of the calling method to aspect
I want to get the field name of the [Java] field. (Old tale tone)
I want you to use Enum # name () for the Key of SharedPreference
[RxSwift] I want to deepen my understanding by following the definition of Observable
I want to get the value of Cell transparently regardless of CellType (Apache POI)
I want to control the start / stop of servers and databases with Alexa
I want to see the contents of Request without saying four or five
I want to recursively get the superclass and interface of a certain class
I want to design a structured exception handling
I want to truncate after the decimal point
I want to get the value in Ruby
Call API [Handling]
I tried to check the operation of http request (Put) with Talented API Tester
I want to hit the API with Rails on multiple docker-composes set up locally
I want to reduce the number of unnecessary queries. From considering counter_cache to introducing counter_culture.
[Java] I want to calculate the difference from the date
I want to embed any TraceId in the log
I was addicted to the record of the associated model
05. I tried to stub the source of Spring Boot
I want to judge the range using the monthly degree
I tried to reduce the capacity of Spring Boot
I want to dark mode with the SWT app
[Rough commentary] I want to marry the pluck method
I want to simplify the log output on Android
I want to add a delete function to the comment function
I want to fetch another association of the parent model from the intermediate table with has_many
[Ruby on Rails] I want to get the URL of the image saved in Active Storage
I tried to make the sample application into a microservice according to the idea of the book "Microservice Architecture".
I want to get a list of the contents of a zip file and its uncompressed size
I want to change the color of the upper control navigation bar (Control menu) in Liferay 7 / DXP
Implemented a strong API for "I want to display ~~ on the screen" with simple CQRS
I want to recreate the contents of assets from scratch in the environment built with capistrano
[Beginner] I want to modify the migration file-How to use rollback-
[Rails] [bootstrap] I want to change the font size responsively
I want to use screen sharing on the login screen on Ubuntu 18
(ยด-`) .. oO (I want to easily find the standard output "Hello".