bluejay
bluejay copied to clipboard
Provide an option to call regular Bluejay API on the main thread while a background task is running
There is a valid reason to support this, as Nigel have explained in a pull request to not only prevent calling regular Bluejay API inside a background task, but also on the main thread while a background task is running.
But you can have use case that are reasonable when you know the order of the task doesn't matter for a specific set of operations.
As a concrete example, say you have a device that has a bunch of data collected on the device than can be synced in one of the standard "big sync" operations we'd use background task for and also has a battery level that is displayed on one screen in the app. You kick off a sync, start navigating around while the sync is running and get to the screen that has the battery indicator on it. In that case reading the battery level with a normal read from that view controller while the sync was going on in the background would be totally reasonable, because you know in that case there is no dependancies.
Question is, is there a good way to allow that, without making it less likely to be safe in the default case? Best I can come up with is to have a initialization option to allow this. So if you set "allowBackgroundOverlap" or something at create time, it disables these errors in the cases that might be safe (i.e. it would still always be an error to call them from inside a background task).