Fork me on GitHub
#scittle
<
2024-06-28
>
fs4220:06:51

Is there example code to load and use the supabase js lib from within scittle? <script src="https://cdn.jsdelivr.net/npm/@supabase/supabase-js@2"></script>

borkdude20:06:43

what isn't clear about this? there is an example in that README which should be relatively easy to port to CLJS?

borkdude20:06:38

const { createClient } = supabase
  const _supabase = createClient('', 'public-anon-key')
=>
(def create-client js/supabase.createClient)
(def -supabase (create-client "...", "..."))

fs4221:06:00

Yes I read that. ... maybe I'm still intimidated by how simple and powerful this scittle of yours is 😉 I'll give it a try!

borkdude21:06:48

sure! let me know if it works :)

fs4219:07:24

Ok... I got it to work but with some "quirks". I have a gist with the working supabase.js thought javascript as the example to use for the equivalent cljs: https://gist.github.com/franks42/e19d26cb7e2d1d80b93b34d61f81e9a8

fs4219:07:28

and I have the equivalent working scittle/cljs in the following gist: https://gist.github.com/franks42/c3a3edd9cae3a863458ff46a912374fb

fs4219:07:48

The quirks that I am seeing are also mentioned in the gist comment: • the supabase.js expects you to build-up the complete query before sending it off to the server... which makes sense. In cljs I tried to mimic is first by threading it with p/-> but that didn't work... not sure if the macro-expansion gets in the way... difficult to debug for a mere mortal. • The other issue is that the p/-> after the result comes back and fed to js->clj doesn't give the right result (?)... only after passing it through a trivial fn, it seems to work - magic as far as I can see.

fs4219:07:41

Any insides from the sensei here?

borkdude20:07:09

Full repro or else it’s hard to say

borkdude20:07:55

Possible you're getting back a promise and if you're processing that with clj->js it just stays a promise

fs4222:07:46

Pls take a look at: https://franks42.github.io/supabase-test/index.html which should show you the working examples in js and cljs fetching from my supabase db instance. (I double checked and as I understand it, it's "ok" to share the api-key for public access... the test db and key is useless anyway after this all is resolved)

fs4222:07:39

(I test it locally with "bb dev --port 1338")

borkdude07:07:46

> In cljs I tried to mimic is first by threading it with p/-> but that didn't work You can debug this as follows:

(p/let [query (whatever)
        _ (js/console.log query)
        ]
  (.supabase query))

borkdude07:07:07

I recommend doing that style of debugging for the second issue as well. Let me know how it goes

fs4216:07:13

Ok - I’ll give it a try - thanks.