Related: I binned off Core Data for Big Mail 2, and instead have been using the phenomenal GRDB by @groue
Not only is my app now faster and less buggy, but it’s so much easier to reason with. No weird managed contexts and elaborate dances to pass stuff between threads. Just simple, safe, Swift structs.
(Also, the documentation is INSANE) https://github.com/groue/GRDB.swift
There's also a sister package, GRDBQuery, which gives you a @Query property wrapper for SwiftUI (similar to @FetchRequest in Core Data)
You're then able to write views that automatically update when anything in the database changes.
Here's all the code needed for the account picker in Big Mail. So clean.
Writing these packages has also been a fun exercise in how to design APIs now that we have concurrency.
For example, subscribing to IMAP idles (pushed events), I borrowed the 'updates' pattern used in the new StoreKit 2 API. It's an AsyncStream that just runs forever, and gets iterated over when new events occur.
This concludes this morning's stream of consciousness.
Tune in tomorrow!