Post

Working on a new schema (at last 😆), I decided I need to move my data interaction to app intents (yet another excuse 😅), as then I'll have one point to change my logic after schema migration. However, that means I need to extract my logic first, and it made me realize one thing…

I hate notification scheduling on iOS. 😩 The main problem I have right now with moving my code to intents is that I need to handle notifications scheduling correctly, and today I realized why I hate that API so much. It’s asynchronous!

Don’t get me wrong, most of the APIs that are asynchronous are fine. The problem in my case is that I need to be able to call methods from different places and for them to be executed synchronously.

I created my handler in a way that enqueues the operations to an async stream and executes them on a background thread in the proper order, but it looks and feels like a very dirty workaround. Especially since I need to be sure that it finishes in a few places.

0 reposts0 likes

That forced me to create yet another horrible solution when waiting for execution to finish means I close the async stream, wait for the background task to end, and recreate the stream with its background handler.

Even the description sounds horrible. 😬 Moreover, I believe there are cases when something might go wrong, but I just haven’t encountered them yet. I thought the actors could save me here, but reentrancy means every await call makes my actor method calls interleave. 😩