Hi all,
So long long ago, I wrote a Promise class for our GWT project to make easier to write complex async code that ran in the browser but could also be run in Junit tests running in the plain JRE, and sometimes on the server in cases where we could assume the Promise would complete synchronously.
Fast forward 10+ years, and the Promise has long been standardized and baked into browsers themselves, WITH great support in DevTools for following the path of a Promise across resolutions.
I'm refactoring this class to use the browser's native Promise implementation. Normally the way I would do this is:
1. Align the Java implementation class to the Browser's Promise API
2. Add a supersource implementation that uses JSNI to invoke the browser's API when compiling.
BUT - is this still the "best" way to do this in 2025, with @JsTypes?
AND - there is already a Promise class in the elemental library that we use extensively, but it's a "native" class, so we can't use it in the JRE. Can I provide a JRE-safe implementation of elemental2.promise.Promise without monkey-patching elemental2-promise ?
Has anyone else implemented something similar?
Best,
Alex