clojurescript

ClojureScript, a dialect of Clojure that compiles to JavaScript http://clojurescript.org | Currently at 1.10.879
zendevil 2021-01-07T01:57:21.187100Z

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

zendevil 2021-01-07T01:58:34.187400Z

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

zendevil 2021-01-07T02:05:49.188100Z

How to fix this error?

p-himik 2021-01-07T08:42:04.188600Z

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 2021-01-07T10:48:06.191700Z

it works now

zendevil 2021-01-07T10:45:23.189800Z

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

zendevil 2021-01-07T10:45:57.190Z

This is how I’m using it:

zendevil 2021-01-07T10:46:00.190300Z

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

zendevil 2021-01-07T10:46:08.190600Z

And this is how it’s imported

zendevil 2021-01-07T10:46:25.190900Z

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

zendevil 2021-01-07T10:46:33.191200Z

And the error I’m getting is the following:

zendevil 2021-01-07T10:47:09.191500Z

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

simongray 2021-01-07T11:32:35.192800Z

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

simongray 2021-01-07T11:33:45.193600Z

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

zendevil 2021-01-07T12:20:09.193900Z

it was because :refer should be :default

dnolen 2021-01-07T14:17:16.195300Z

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

dnolen 2021-01-07T14:17:36.195800Z

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

dnolen 2021-01-07T14:18:41.197100Z

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

👀 1
thheller 2021-01-07T14:21:58.197500Z

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

👍 1
dnolen 2021-01-07T14:38:01.198700Z

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

dnolen 2021-01-07T14:38:55.199800Z

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

2021-01-07T17:20:16.206900Z

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.

thheller 2021-01-08T10:27:11.219900Z

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

thheller 2021-01-08T10:31:48.220300Z

I'll make a new release soon

thheller 2021-01-08T13:50:11.220700Z

fixed in 2.11.12

byrongibby 2021-01-07T17:47:22.207800Z

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

dnolen 2021-01-07T17:48:06.208200Z

JavaScript doesn't have portable I/O

byrongibby 2021-01-07T18:09:06.208600Z

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

dnolen 2021-01-07T18:09:53.209400Z

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

dnolen 2021-01-07T18:10:16.209900Z

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

byrongibby 2021-01-07T18:11:01.210600Z

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

2021-01-07T18:11:56.211Z

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

2021-01-07T18:12:24.211300Z

as opposed to browser-hosted cljs?

byrongibby 2021-01-07T18:17:05.214Z

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.

2021-01-07T18:27:54.215300Z

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.

2021-01-07T18:28:25.215900Z

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

byrongibby 2021-01-07T18:37:28.216100Z

Thanks, much appreciated!

thheller 2021-01-07T19:35:23.216200Z

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

👍 1