Fork me on GitHub
#clojurescript
<
2019-02-17
>
kwladyka16:02:36

Can't take value of macro cljs.core/or How to fix it?

kwladyka16:02:10

and why this issue?

kwladyka16:02:58

Doest it mean I can’t use or with re-frame/subscribe values?

kwladyka16:02:00

(some identity [logged? sign-up?]) can be a solution

kwladyka16:02:13

anyway I changed logic to not use or, but it is interesting issue

thheller16:02:38

@kwladyka that appears to be a bug in figwheel. others have reported the same with and. apparantely this fixes it https://github.com/bhauman/figwheel-core/pull/2

👍 5
🍻 5
jaide19:02:11

When using reagent, I have a component that needs to listen to keyboard events on the document when mounted. Is there an example, guide, or sample for how to best handle that?

Daw-Ran Liou19:02:22

Beginner question here: when I create a javascript object, e.g. (react/createContext "hi"), from my repl, why do I get nil back in the repl? However, I can also find the js object show up in the browser console. Is this the right behavior or did I mess up something? Thanks.

workshop.core> (react/createContext "hi")
nil

Daw-Ran Liou19:02:07

BTW I’m using shadow-cljs as my cljs repl. Not sure if this is relevant.

jaide19:02:40

When invoked from the console in vanilla js does it return an object or is it a side-effect?

Daw-Ran Liou19:02:12

It returns an object:

React.createContext()
Object { "$$typeof": Symbol(react.context), _calculateChangedBits: null, _currentValue: undefined, _currentValue2: undefined, _threadCount: 0, Provider: {…}, Consumer: {…}, _currentRenderer: null, _currentRenderer2: null }

lilactown19:02:25

@dawranliou what’s happening is the CLJS printer is barfing on the Symbol(react.context) JS value

lilactown19:02:11

if you check the browser console you should see an error pertaining to it

lilactown20:02:10

you can fix it using these 4 lines:

(extend-protocol IPrintWithWriter
  js/Symbol
  (-pr-writer [sym writer _]
    (-write writer (str "\"" (.toString sym) "\""))))

Daw-Ran Liou20:02:43

Thanks @lilactown ! This is very useful. I need this in all my cljs project now

TobiH22:02:03

@dpsutton So... I finally got it working. But what I found does also not make not much sense to me. It seems that it has something todo with Gnome. Every distro that uses a Gnome desktop did not give me the repl prompt after a reboot. But if I used KDE or XFCE it works alright.

dpsutton22:02:03

hmm. that is bizarre to me. there's something funky going on. but no idea