I have to handle quite a lot of text data and do some computationally expensive operations on it (parsing and building a data structure from it), so I want to use a webworker for that, but it seems like there is no simple way to pass a cljs data structure from the main thread <-> webworker, should I be using something like https://github.com/mfikes/cljs-bean for serialization/deserialization ?
or are there better ways
Because js->clj doesn't seem to work in this case
try clj->js
when sending and js->clj
when receiving?
I did to no avail. I'm not home atm so I cannot show the error, will do when I come back
if you're trying to serialize cljs data in the browser, you should check out https://github.com/cognitect/transit-cljs
will check it out thanks
Hi, I have a problem using Clojurescript, Figwheel and now trying to add firebase to my project. I get this:
[Figwheel:WARNING] Could not Analyze: Could not locate cljs/core/async/macros__init.class, cljs/core/async/macros.clj or cljs/core/async/macros.cljc on classpath.
I am new to clojure and clojurescript and was thinking about moving from Vue into reagent
I don't understand why this problem came when I added firebase to my package.json
i tried to remove firebase but the problem is still there. now I have no idea at all
sorry for bothering you, i found out why :man-facepalming:
It's probably not related to Firebase at all.
Try adding org.clojure/core.async
to your dependencies.
Ah, I missed the "found out" part. :) What was it?
yeah, I found out that I did remove the dependecy while still require the async macros
I'm having a hard time getting a project up with my components that I need.
i have a project up and running with figwheel now. However, I can't seem to use Firebase API
should I try to set up a new project using shadow-cljs?
Since you're just starting with CLJS, I would recommend it, yes. Personally, I had almost 0 problems with it. And the ones that I did have were caused by my unconventional usage patterns, not by the tool itself.
it seems to be easier to use "native" libs with shadow-cljs
want to make a prof of concept migration to clojurescript to get rid of our Vue-spaghetti
Yes, I have found it much easier to use JS libs with shadow-cljs. I've never tried figwheel-main though and some people say that it's just as good. But its documentation is not that great and I still occasionally see reported issues being mentioned.
Hello I am using shadow-cljs for a react native application. Every is working except for hot code reload on my iPhone simulator. I have disabled Expo fast refresh but I still have to reload manually after recompiling.
Hey guys... Need some help with using sourcemap on http://sentry.io I have this electron app written with cljs and generate sourcemap at with shadow-cljs. I have uploaded them successfully to sentry and but they don't seems to work there: I think it is not working because sourcemap files contain cljs namespaces but sentry error files doesn't... please can anyone help me with this?
Now I have a shadow-cljs project running. I have added Firebase to the package.json but I just can't call Firebase.initializeApp
I'm not sure what I am doing wrong
TypeError: module$node_modules$firebase$dist$index_esm.initializeApp is not a function
(ns <http://percap.admin.app|percap.admin.app>
(:require [reagent.dom :as dom]
["firebase/app" :as firebase]
["firebase/firestore"]))
(defonce firebase-instance (atom nil))
(defn init-firebase [config]
(when-not @firebase-instance
(reset! firebase-instance (firebase/initializeApp (clj->js config)))))
This is my codeI have also tried
(ns <http://percap.admin.app|percap.admin.app>
(:require [reagent.dom :as dom]
["firebase" :as Firebase]))
(defonce firebase-instance (atom nil))
(defn init-firebase [config]
(when-not @firebase-instance
(reset! firebase-instance (-> Firebase (.initializeApp (clj->js config))))))
@fredrik245 see https://shadow-cljs.github.io/docs/UsersGuide.html#_using_npm_packages
ok thanks!
it might be :default firebase
and (.initializeApp firebase ...)
see the section about default export and how to test it in the REPL
ah, right! i saw something about :default before when i was in figwheel-land
back then that didn't work obviously, but now it should
😄 thanks!
it might be. I don't have a clue.
it works now with :default
this is most likely caused by the emulator not being able to connect back to the shadow-cljs process
maybe it picked the wrong IP or so
run shadow-cljs watch app --verbose
and it'll log the IP it used on start
verify that is the correct one
you can easily try connecting to the shadow-cljs process on that IP with port 9630 via a browser in the emulator
it appears that you are maybe mixing outputs. the left is from a development build but the right seems to be from a release
build?
only release
builds are self-contained and have a chance to work with sentry. no clue how sentry handles development builds.
Thank you for your help @thheller!
Yes you are right...
source maps are uploaded from dev build
but will sentry pickup even with .background and other prefix in file name?
so I don't use sentry or develop electron apps so I do not have a clue
Thanks man!! you hinted me in right direction... release command for electron create one single master main.js and main.js.map and that will solve our problem
Does anyone know if it's possible to perform an effect when the number of views depending on a subscription reaches zero? Specifically with re-frame.
#re-frame is a better place for such questions.
You can add such a handler with re-frame.interop/add-on-dispose!
. I don't think it's a public API though. I'm also pretty sure that the fact that subs are disposed of as regular atoms when their views no longer need them is an implementation detail, so be aware.
Oh thank you. I didn't see that channel. Thanks for the pointer as well
This will probably be useful to you as well: https://day8.github.io/re-frame/FAQs/LoadOnMount/ Since what you want is somewhat conceptually similar.
Hmm maybe. What I'm trying to do is unsubscribe from a re-graph subscription when it's no longer necessary. The re-graph subscription is started when the view subscription is initiated. I was looking for a way to clean up the graphql subscription when the user moves to another page and no longer needs that information kept live in the app-db.
What does "subscribing to a re-graph subscription" mean exactly? If it's a regular re-frame sub, then it will all be done automatically.
The re-graph subscription opens a websocket connection to a graphql server and receives events as a stream which get handled by a reg-event-db handler. My concern is that the stream will be kept open and processing events after the user no longer cares for them.
Is there any code in re-graph that closes that connection?
It appears that it's a manual effect
;; stop the subscription
(re-graph/unsubscribe :my-subscription-id)
Ah, they're following the re-frame documentation that I linked above.
There are events, :re-graph.core/subscribe
and :re-graph.core/unsubscribe
, and you should dispatch
them when you need and don't need the data. As soon as you stop focusing on views, it will all become clear.
A hint in advance - if you have multiple events that make a single view appear and you don't want to change all those events, you can use a single global interceptor for that which would monitor something like a single :is-that-view-visible?
flag in the app-db and dispatch the right re-graph event when the flag's value is changed.
Makes sense. Thanks for the help!
NP
I wonder how I would check if a property or function is defined on a native JS object?
(not (undefined? (.-prop obj)))
thanks, didn't know about undefined
I know js*
is an internal thing that we're not supposed to use but is there any documentation on how it works? I couldn't find a blog post or anything.
documenting it would lead to people using it so its not 🙂
lol
but it's likely not going away any time soon
yes but people almost always use it for the wrong reasons. at least all the occasional mentions I've seen in this channel were abusing stuff that shouldn't be done 😛
js*
really doesn't do much, just takes the string you give it and placed it into the output as is. optinally interpolating some values
(js* "some(~{})" "foo")
would give you some("foo")
in the code
ah i see
thanks!
what are you up to? 😛
oh I'm actually not using it for anything, just pure curiosity