This is my initial attempt at using Model that can be instantiated on the fly.
While this sort-of works, most Views rely on CoreBluetooth
-specific data to update their UI, which still makes it difficult to work with actual previews.
I think for this to work properly, I'd need to write protocols encompassing most of CoreBluetooth
's types (CBManagerState
, CBService
, CBCharacteristic
, ...) so that I can then instantiate mocks (this should also help with writing tests later on).
So something like:
protocol ManagerState
protocol Service
protocol Characteristic
protocol Peripheral
protocol Manager
Then:
- Extends related
CoreBluetooth
types to make them conform to those protocols
- Write Mocks which also conform
- Refactor views to rely on types which implement the protocols
- Refactor previews to use mocks
- ???
- profit
Let me know if this makes sense, it's quite a substantial effort but would definitely come in handy imo. If it does, I'll use this PR to work on this :)