Fork me on GitHub
#clojurescript
<
2024-02-10
>
andrea14:02:04

Anyone working with Dexie and Promesa? Somehow Promesa can handle plain js promises but doesn't recognize Dexie.Promise as Promise EG

(ns fiddle
  (:require
   [promesa.core :as p]
   ["dexie" :as dexie]))

(let [js-promise      (new js/Promise #(%1 "my-js-promise works"))
      dexie-promise   (new dexie/Dexie.Promise #(%1 "dexie-promise won't work"))
      wrapped-promise (js/Promise.resolve
                       (new dexie/Dexie.Promise #(%1 "wrapped dexie-promise works")))]

  (p/then js-promise js/console.log)
  (p/then dexie-promise js/console.log)
  (p/then wrapped-promise js/console.log))
Logs
my-js-promise works
DexiePromise {_listeners: Array(0), …}
wrapped dexie-promise works
I don't know enough about js promises but await does work on Dexie.Promise . Is this something I could fix in Promesa? Also I'm just evaluating Promesa to see if it's actually nicer to work with than plain promises, any suggestions on something different is welcome.

thheller14:02:34

you need to do this, just for the dexie.promise type (whatever that is) https://github.com/funcool/promesa/blob/master/src/promesa/impl.cljc#L91

🙏 2