scittle

fs42 2024-06-28T20:19:51.277329Z

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>

borkdude 2024-07-03T07:57:46.981849Z

> 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))

borkdude 2024-07-03T07:58:07.177299Z

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

fs42 2024-07-03T16:15:13.500109Z

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

borkdude 2024-06-28T20:25:57.200829Z

it seems you're using this, right: https://github.com/supabase/supabase-js?tab=readme-ov-file#umd

borkdude 2024-06-28T20:26:43.408159Z

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

borkdude 2024-06-28T20:27:38.913479Z

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

fs42 2024-06-28T21:11:00.936299Z

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!

borkdude 2024-06-28T21:11:48.304719Z

sure! let me know if it works :)

fs42 2024-07-02T19:11:24.609699Z

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

fs42 2024-07-02T19:12:28.070009Z

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

fs42 2024-07-02T19:15:48.910599Z

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.

fs42 2024-07-02T19:18:41.891139Z

Any insides from the sensei here?

borkdude 2024-07-02T20:17:09.719649Z

Full repro or else it’s hard to say

borkdude 2024-07-02T20:18:55.786009Z

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

fs42 2024-07-02T22:25:46.825199Z

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)

fs42 2024-07-02T22:26:39.507189Z

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