ipywidgets icon indicating copy to clipboard operation
ipywidgets copied to clipboard

Change Promises to Async/Await

Open jmk89 opened this issue 3 years ago • 8 comments
trafficstars

Some were simple and some were not

jmk89 avatar Sep 04 '22 01:09 jmk89

Binder :point_left: Launch a binder notebook on branch jmk89/ipywidgets/promisetoasync

github-actions[bot] avatar Sep 04 '22 01:09 github-actions[bot]

This is a replacement to https://github.com/jupyter-widgets/ipywidgets/pull/2779

jmk89 avatar Sep 04 '22 01:09 jmk89

I wonder what this means for performance (having skimmed over https://v8.dev/blog/fast-async ). I might do a comparison before/after to see if it does matter.

maartenbreddels avatar Sep 27 '22 18:09 maartenbreddels

Having some trouble figuring out what to do about the failing checks. Particularly I can't replicate the Error: src/widget.ts(289,5): error TS2322: Type 'Dict<unknown>' is not assignable to type 'Dict<BufferJSON>'. on my local machine when I run ./dev-install.sh or a clean/build.

The build error is happening in a method I refactored out of _handle_comm_msg. It's nearly a copy and paste of the original promise callback function. Any advice is welcome.

jmk89 avatar Sep 28 '22 02:09 jmk89

@jmk89 This is due to the change in the this context. I will add a suggestion shortly

ibdafna avatar Sep 28 '22 02:09 ibdafna

@jmk89 Here is a commit I added last week to fix the issue of not compiling: https://github.com/ibdafna/ipywidgets/pull/1/commits/c4f468eaa2714d4061b7c986fb888e712022700d

ibdafna avatar Oct 11 '22 16:10 ibdafna

As an update, we discussed this in the ipywidgets dev meeting, and a few of us will have more time to look at this next week during the widgets dev workshop. Thanks!

jasongrout avatar Oct 11 '22 17:10 jasongrout

@jmk89 I am happy to push the fix above, directly to this branch, with your permission! 🙏

ibdafna avatar Oct 11 '22 17:10 ibdafna

@ibdafna sounds good to me, thanks for asking 😄 . Although I'm not fully understanding the fix 😅 - it seems to me like setting the state_change to the awaited state_change breaks the "chain of state change" which was being queued.

It's quite likely that I'm misunderstanding, if there's any enlightenment you can forward my way I'd appreciate it 😄

jmk89 avatar Oct 14 '22 00:10 jmk89