cacao icon indicating copy to clipboard operation
cacao copied to clipboard

Async, Background, and Local Dispatchers support

Open JoshuaBrest opened this issue 1 year ago • 4 comments

I think we should add the following features to make development easier:

  • Async
    • Maybe you need to call async functions
    • Could be done by calling a background task to modify the view later instead of in the did_load
  • Background
    • Maybe a background task might be useful for like setInterval
  • Local Dispatcher
    • So that instead of adding complicated logic in App, you can do it in the local view impl

JoshuaBrest avatar Apr 27 '23 03:04 JoshuaBrest

See some of the previous discussion on this in https://github.com/madsmtm/objc2/issues/279.

In short: async Objective-C is difficult, and especially difficult to make efficient!

madsmtm avatar Apr 27 '23 21:04 madsmtm

I'm neither for nor against this conceptually, but I think I'd ultimately defer to anything @madsmtm does upstream in objc2 - which cacao needs to ultimately rebase on and finally merge anyway.

We can keep this open as a general tracking issue and I'll label it accordingly, but don't expect much for some time.

ryanmcgrath avatar Apr 28 '23 19:04 ryanmcgrath

For the local dispatcher, i think it would be possible if we added lifetimes or just used unsafe. It should be fine if we unregister the fn,

JoshuaBrest avatar Jul 11 '23 23:07 JoshuaBrest

@ryanmcgrath As I was discovering about objc it turns out the handlers are called in a different whole context where memory in the main thread is not even accessible from a rust fn.

JoshuaBrest avatar Aug 04 '23 23:08 JoshuaBrest