This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2024-06-28
Channels
- # announcements (1)
- # beginners (128)
- # calva (15)
- # cider (1)
- # clerk (4)
- # clj-kondo (10)
- # clojure-berlin (5)
- # clojure-denmark (2)
- # clojure-europe (59)
- # clojure-nl (2)
- # clojure-norway (83)
- # clojure-sweden (3)
- # clojure-uk (4)
- # cursive (11)
- # datomic (8)
- # emacs (13)
- # events (1)
- # hyperfiddle (3)
- # juxt (2)
- # malli (13)
- # nrepl (10)
- # off-topic (46)
- # releases (2)
- # reveal (1)
- # rewrite-clj (6)
- # sci (6)
- # scittle (17)
- # shadow-cljs (2)
- # xtdb (2)
- # yamlscript (8)
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>
it seems you're using this, right: https://github.com/supabase/supabase-js?tab=readme-ov-file#umd
what isn't clear about this? there is an example in that README which should be relatively easy to port to CLJS?
const { createClient } = supabase
const _supabase = createClient('', 'public-anon-key')
=>
(def create-client js/supabase.createClient)
(def -supabase (create-client "...", "..."))
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!
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
and I have the equivalent working scittle/cljs in the following gist: https://gist.github.com/franks42/c3a3edd9cae3a863458ff46a912374fb
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.
Possible you're getting back a promise and if you're processing that with clj->js
it just stays a promise
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)
> 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))