Description
To implement any kind of async callbacks from C to Dart, we have to jump through some hoops, see the following issues:
- [vm/ffi] Support asynchronous callbacks dart-lang/sdk#37022
- dart:ffi asynchronous C execution dart-lang/sdk#35766
- How to use async callback between C++ and Dart with FFI? flutter/flutter#63255 (comment)
In short, native callbacks must be executed on the "right" dart isolate, during its event loop.
This issue currently affects observers (#142) and is a prerequisite for SyncClient
listeners (#140).
From my understanding, getting this to work is quite a bit involved because we would need to create some custom C code that would call directly into dart APIs to inject the callback into the event loop (forgive if this is inaccurate, still learning about the workaround). AFAICT this would require that we either ship a different version of the objectbox-c or we create an additional one we ship alongside the standard one used by all other languages...