levibostian / iOSBlanky

My opinionated iOS app boilerplate
MIT License
6 stars 5 forks source link

Remove RxSwift #51

Closed levibostian closed 2 years ago

levibostian commented 3 years ago

I have been trying hard to make my tech stacks as simple as possible. The less amount of tools being used, the less amount of things to debug, less time to compile, less tools to learn how to use.

RxSwift is one of those tools that is very large in size while I am using a fraction of it. It's also a tool that is difficult to learn. If it was a tool that I used the whole code base or I was able to download only a fraction of the Rx tool, I may consider keeping it. But at this time, it's like buying a house but only living in the bathroom all day. Might as well move into a smaller house.

Requirements

Thinking to how I use RxSwift, here are requirements I need for a replacement.

Tasks

Proposal

Create something that I use in the ViewModel. Something like backgroundTask.background { queueUtil → … } I have this code when the function first starts so that everything inside of it runs on a background queue.

This backgroundTask function returns a struct or new class back. Something that is destroyed when it’s done being used. Not a singleton, not a class that handles 1+ tasks running at once. 1 instance per task.

The returned class/struct is able to call assertMain() on it or similar function to check what function we are on. The struct/class keeps track internally via properties what queue is currently being executed. Check with properties because then a simulator can check these properties instead of running real dispatch queue code to check what queue we are on.

Make sure I can mock this backgroundTask class. Then in my tests, I can say “assert this is the order of operations: [background, background, UI] for each call to the class”. My tests I just need to confirm that the task started off on the background and ended in the UI. Maybe there is a way in my callback parameter I can check what queue is currently running.