Fork me on GitHub
#clojurescript
<
2021-01-07
>
zendevil.eth01:01:21

when importing [ajax.edn :as edn], I’m getting the error that ajax.edn is not availabel

zendevil.eth01:01:34

even though I have cljs-ajax/cljs-ajax {:mvn/version “0.8.1”} in my deps.edn

zendevil.eth02:01:49

How to fix this error?

p-himik08:01:04

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.

zendevil.eth10:01:23

I’m getting an error while using react native async storage

zendevil.eth10:01:57

This is how I’m using it:

zendevil.eth10:01:00

(reg-event-fx
 :_id-persist
 (fn [coeffects [_ id]]
   
   (go
     (try
       (<p! (. AsyncStorage setItem "_id" id))
       (catch js/Error e (prn "error is " e))))
   {}
   ))

zendevil.eth10:01:08

And this is how it’s imported

zendevil.eth10:01:25

["@react-native-async-storage/async-storage" :refer [AsyncStorage]]

zendevil.eth10:01:33

And the error I’m getting is the following:

zendevil.eth10:01:09

"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?

simongray11:01:35

id is undefined so go check why whatever you’re passing in as id is undefined rather than an object.

simongray11:01:45

The error doesn’t seem to be in the code you’ve quoted, so go one level up

zendevil.eth12:01:09

it was because :refer should be :default

dnolen14:01:16

just noting that :default is a shadow-cljs thing, not a standard thing

dnolen14:01:36

there's a new generic feature that let's you get at properties of the library as the library itself

dnolen14:01:41

(:require [foo.bar$default :as foo]) , but it also works for a bunch of other cases, React Native Native library imports etc.

👀 3
thheller14:01:58

@dnolen I don't think that is in any "release" yet. only master right?

👍 3
dnolen14:01:01

oh yeah that's true, we're using a sha at work

dnolen14:01:55

I think it's a probably a little bit easier now to use SHAs w/ CI telling us whether it's good or not

markbastian17:01:16

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.

thheller19:01:23

open an issue on github. could be that its not included in the "known" default npm dependencies list. can't check right now.

👍 3
markbastian04:01:35

Looks like non-maintainers are supposed to go through ask clojure. I posted https://ask.clojure.org/index.php/10028/repl-error-workerthreads-is-not-available with details.

thheller10:01:11

open an issue on the shadow-cljs repo I meant. this is a shadow-cljs issue not CLJS

thheller10:01:48

I'll make a new release soon

thheller13:01:11

fixed in 2.11.12

byrongibby17:01:22

Hi, noob here. Why can't I use slurp in ClojureScript (I am using shadow-cljs)?

dnolen17:01:06

JavaScript doesn't have portable I/O

byrongibby18:01:06

I see, thanks, I'll make another plan.

dnolen18:01:53

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

dnolen18:01:16

so you couldn't even implement a slurp which matches the one in Clojure

byrongibby18:01:01

That's a bit of a headache. I miss Clojure all of a sudden. Got some learning to do.

manutter5118:01:56

Are you doing Node.js or some other server-side cljs?

manutter5118:01:24

as opposed to browser-hosted cljs?

byrongibby18:01:05

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.

manutter5118:01:54

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.

manutter5118:01:25

Also there's a #re-frame channel you can post questions to.

byrongibby18:01:28

Thanks, much appreciated!