Roll your own networking stack
summary
Refactors a massive view controller into a tiny composable networking layer built in Swift using URLSession. Claims simple cases stay easy while hard cases remain possible by using a Requestable protocol to hold path and headers, a Resource<T> generic that carries a decode closure, and an APIClient with Environment that supplies baseURL and common headers. Shows a JSONDecoder keypath helper, default protocol implementations, and says the whole stack fits in ~100–150 lines and makes networking testable and concise.
AI-written summary · about
chapters (11)
- 0:00Introduction
- 1:23Code refactoring goal
- 2:51Massive view controller
- 5:45Modeling requests
- 7:58Requestable protocol
- 11:56Handling responses
- 15:43Generic resources
- 19:28Network environments
- 23:02API client abstraction
- 25:06Summary and takeaways
- 27:47Q&A session
related talks
39mOnion-like iOS Architecture Solution
36mA Protocol for Composition
44mSeparation of concerns: Refactoring view controllers live
27mLow-Hanging View Controller Fruits
53mRefactor Your Way Forward
38mFly Me To The View
17mAchieving Loose Coupling with Pure Dependency
46mControlling tons of different IoT devices with Swift
