Fork me on GitHub
#clojurescript
<
2017-05-22
>
mattgeb06:05:46

Hiya! Trying to follow this tutorial. https://medium.com/@matus.lestan/how-to-create-decentralised-apps-with-clojurescript-re-frame-and-ethereum-81de24d72ff5 made it pretty far! but got stuck when it told me to start using the Dispatch function in the figwheel REPL

mattgeb06:05:36

I get this error: cljs.user=> (dispatch [:contract/fetch-compiled-code [:contract/deploy-compiled-code]]) ---- Compiler Warning on <cljs form> line:1 column:2 ---- Use of undeclared Var cljs.user/dispatch 1 (dispatch [:contract/fetch-compiled-code [:contract/deploy-compiled-code]]) ^--- ---- Compiler Warning ---- #object[TypeError TypeError: Cannot read property 'call' of undefined] "nil"

jumar06:05:13

@mattgeb I guess that article references re-frame.core/dispatch which is not in cljs.user namespace but rather in re-frame.core namespace - you need to require re-frame.core namespace

mattgeb06:05:51

Thanks! I'll poke around try to add it.

mattgeb06:05:12

Whoo, progress! Little hacky, but I did a quick (require 're-frame.core)

mattgeb06:05:30

then changed the dispatch call to (re-frame.core/dispatch [:contract/fetch-compiled-code [:contract/deploy-compiled-code]])

mattgeb06:05:43

now there's a new error! log4j:WARN No appenders could be found for logger (onelog.core). log4j:WARN Please initialize the log4j system properly. log4j:WARN See http://logging.apache.org/log4j/1.2/faq.html#noconfig for more info.

mattgeb06:05:47

Progress! 🙂

dimovich10:05:53

Greetings all

dimovich10:05:19

trying to use :npm-deps option of clojurescript

dimovich10:05:29

but getting an error

dnolen12:05:32

@lxsameer do you mean just async loading a namespace?

dnolen12:05:58

if so Google Closure Library has support for that

lxsameer12:05:54

@dnolen yes, but to be clear, I want to load namespaces on demand

lxsameer13:05:09

@thheller yeah, but shadow-cljs is in alpha stage, right ?

thheller13:05:40

@lxsameer sort of yes but that is mostly because of the new stuff

thheller13:05:21

:browser is pretty solid and what I have been using for 3+ years

lxsameer14:05:40

@thheller :browser is a cljs compiler feature, right ?

thheller14:05:06

its a configuration preset from shadow-cljs

lxsameer14:05:47

@thheller cool, I'm going to try it

vargaradu14:05:17

Anyone having experience integrating websockets with re-frame? I was trying to integrate Sente, but not sure how do it it correctly.

thheller14:05:22

cool, I’m here if you have questions

vargaradu14:05:06

what library did you use and how did you hook it to re-frame events?

lxsameer14:05:44

vargaradu: hey

lxsameer14:05:51

I'm using sente

lxsameer14:05:24

shoot any question you have

vargaradu14:05:32

thanks, I’ll give it a try!

lxsameer14:05:09

cool. If you're looking for a project which I used this solution

vargaradu16:05:19

is it just me or this Sente library is more complicated than it should be?

lxsameer16:05:47

no it's very easy to use

lxsameer16:05:09

while you set it up with re-frame then you can forget about it completely

lxsameer16:05:33

@vargaradu it goes well with re-frame anatomy

vargaradu16:05:18

Ok, got the hang of it in the end, still took some github issue readings to figure out everything. Thanks for the code, it was very helpful!

lxsameer21:05:59

glad to help

thheller14:05:03

@dsapoetra probably missing externs

thheller14:05:20

not sure what ReactComponentTreeHook is though

thheller14:05:56

oh wait nevermind. is that with :advanced?

thheller14:05:05

maybe incompatible react versions somewhere

dsapoetra14:05:09

@thheller no, it’s with :whitespace

{:id           "desktop"
             :source-paths ["src-cljs-desktop"]

             :compiler     {:main            app.core
                            :output-dir      "resources/public/fe/js/compiled/out-desktop"
                            :output-to       "resources/public/fe/js/app-desktop.js"
                            :closure-defines {"goog.DEBUG" false}
                            :optimizations   :whitespace
                            :pretty-print    false}}

thheller14:05:30

any stack info for the exception? who is trying to call that?

dsapoetra14:05:56

I get that from chrome console, so the stack trace is from compiled js

thheller14:05:10

but it should tell you who was trying to use that

dsapoetra14:05:42

at Object.132 (app-desktop.js:78176)
    at s (app-desktop.js:61161)
    at app-desktop.js:61161
    at Object.50.132 (app-desktop.js:69527)
    at s (app-desktop.js:61161)
    at app-desktop.js:61161
    at Object.64.50 (app-desktop.js:70690)
    at s (app-desktop.js:61161)
    at app-desktop.js:61161
    at Object.75.157 (app-desktop.js:72639)

thheller14:05:01

no source maps?

dsapoetra14:05:32

no, that’s all from chrome console

thheller14:05:41

try “pause on exception” in chrome

thheller14:05:04

the source location should give a hint and enable source maps 🙂

uwo17:05:20

any recommendations on how to overwrite default behavior for cljs.pprint/pprint when it prints functions?

rauh17:05:30

@uwo for dev only I assume? There is an ugly hack

rauh17:05:13

(def dummy-print-fn-sentinel (fn [] "<omitted>"))
(defn dev-disable-fn-print
  "HACKS."
  []
  (let [old js/Function.prototype.toString]
    ;; Skip the following lines, don't judge:
    (when-not (identical? dummy-print-fn-sentinel old)
      (set! js/Function.prototype.toString dummy-print-fn-sentinel)
      (js/setTimeout
        #(set! js/Function.prototype.toString old)
        500))))

uwo17:05:17

@rauh whoa. heh, nothing like overriding print-method in java land then, I guess? 😄

rauh17:05:58

They're quite compact anyways so I never bothered with that.

Al Baker17:05:02

has anyone worked with the Carry framework yet?

husain.mohssen19:05:21

I'm a clojurescript/figwheel noob and I'm stuck on a problem: How do I get multiple pages working with figwheel? I suppose I can have a page2.html and refer to a different .js file and start things that way but: 1. I'm having trouble getting the project.clj to generate two different .js files with different :main functions. 2. I can't quite figure out how to get modules https://clojurescript.org/guides/javascript-modules to do the trick.

husain.mohssen19:05:37

am I thinking about this the wrong way?

thheller19:05:27

@husain.mohssen figwheel does not support :modules in development

husain.mohssen19:05:19

so I should just use different profiles to compile different .js files?

thheller19:05:09

@husain.mohssen you could do that but ideally you want to be able to share code between the pages

thheller19:05:30

say a common.js then a page-a.js and page-b.js

thheller19:05:44

where each page contains only the code for that page

thheller19:05:33

{:common {:entries [cljs.core]}
 :page-a {:entries [my.app.page-a] :depends-on #{:common}}
 :page-b {:entries [my.app.page-b] :depends-on #{:common}}}

thheller19:05:43

module config would look something like that

alex-dixon20:05:19

Is there an equivalent of (let [some-sym# (my-func)]` that works for macros that are used by CLJS? I have a macro that works in Clojure that uses the # syntax but the value of (my-func) isn’t getting bound to it in CLJS

cpmcdaniel20:05:20

is there anything like criterium for benchmarking fns in ClojureScript?

alex-dixon20:05:28

Actually…might be an unrelated issue 😬

joshkh21:05:13

this is probably a dumb question, but how do i go about combining sente with figwheel? figwheel accepts a ring handler, but it doesn't seem to kick off the web socket setup with http-kit.

noisesmith21:05:46

one option is not to use figwheel’s http-server for your code - let figwheel worry about its websocket, and create your own with your own http server for sente

noisesmith21:05:59

this might not be the most elegant option, but it works for my app

joshkh21:05:02

ah right - so start my server manually from the repl

noisesmith21:05:14

yeah, that’s how I do it

joshkh21:05:42

thanks. i'll stop being so lazy and try it out 😉