when importing [ajax.edn :as edn], I’m getting the error that ajax.edn is not availabel
even though I have cljs-ajax/cljs-ajax {:mvn/version “0.8.1”} in my deps.edn
How to fix this error?
After adding that dependency, have you restarted your build tool (regardless of what you're using)? If yes, try removing all cache and output directories and then restarting your build tool again.
it works now
I’m getting an error while using react native async storage
This is how I’m using it:
(reg-event-fx
:_id-persist
(fn [coeffects [_ id]]
(go
(try
(<p! (. AsyncStorage setItem "_id" id))
(catch js/Error e (prn "error is " e))))
{}
))
And this is how it’s imported
["@react-native-async-storage/async-storage" :refer [AsyncStorage]]
And the error I’m getting is the following:
"error is " #object[TypeError TypeError: undefined is not an object (evaluating 'shadow.js.shim.module$$react_native_async_storage$async_storage.AsyncStorage.setItem')]
How to fix this error?id is undefined
so go check why whatever you’re passing in as id is undefined
rather than an object.
The error doesn’t seem to be in the code you’ve quoted, so go one level up
it was because :refer should be :default
just noting that :default
is a shadow-cljs thing, not a standard thing
there's a new generic feature that let's you get at properties of the library as the library itself
(:require [foo.bar$default :as foo])
, but it also works for a bunch of other cases, React Native Native library imports etc.
@dnolen I don't think that is in any "release" yet. only master right?
oh yeah that's true, we're using a sha at work
I think it's a probably a little bit easier now to use SHAs w/ CI telling us whether it's good or not
I’m running into an issue when loading a ns with a dependency on a js library that is giving me the error (in part): “The required JS dependency “worker_threads” is not available…” Typically I resolve these by using npm install or yarn add for the missing library as described https://shadow-cljs.github.io/docs/UsersGuide.html#_missing_js_dependency. However, it looks like ‘worker_threads’ is part of node since v12. I am on v15.5.1. Any idea what I need to do to get this working? I am using shadow-cljs.
open an issue on the shadow-cljs repo I meant. this is a shadow-cljs issue not CLJS
fixed in https://github.com/thheller/shadow-cljs/commit/87515b0268daa3a27da427970881c195c7fa5536
I'll make a new release soon
fixed in 2.11.12
Hi, noob here. Why can't I use slurp in ClojureScript (I am using shadow-cljs)?
JavaScript doesn't have portable I/O
I see, thanks, I'll make another plan.
also JS I/O in the environment where it exists (which isn't even compatible really btw. Node.js vs Browser) - it must be async
so you couldn't even implement a slurp which matches the one in Clojure
That's a bit of a headache. I miss Clojure all of a sudden. Got some learning to do.
Are you doing Node.js or some other server-side cljs?
as opposed to browser-hosted cljs?
Browser-hosted, working with re-frame. I want to initialise the db with a REST request to another server. I initially thought it should be a synchronous call, but now that I think a little longer, that would block the page from loading. I intend to use cljs-ajax, just need to learn more about re-frame to know what happens if the user tries to access data from the db that has yet to load.
Ok, we do that all the time in our re-frame app, so you're on the right track. We use cljs-ajax in conjunction with day8.re-frame/http-fx, which is a re-frame wrapper around cljs-ajax. Works well.
Also there's a #re-frame channel you can post questions to.
Thanks, much appreciated!
open an issue on github. could be that its not included in the "known" default npm dependencies list. can't check right now.