Fork me on GitHub
#clojurescript
<
2015-09-22
>
venantius06:09:49

Anybody have any experience with charting libraries and Om? I’ve been having some difficulties with Chart.js that are almost certainly not Om issues but I’m curious what other people are doing in any case

venantius07:09:35

coooooooooool

sander09:09:10

hi! i'm getting WARNING: No such namespace: d3, could not locate d3.cljs, d3.cljc, or Closure namespace "" warnings when using cljsjs/d3 "3.5.5-3" with code like (d3/select ".chart"). the compiled script works fine but the warnings are annoying. am i doing something wrong?

martinklepsch09:09:37

@sander: (.select js/d3 …)

martinklepsch09:09:37

@sander: most cljsjs packages don’t expose closure modules but just load foreign libs, adding things to the global js/ namespace as they would do usually

sander09:09:50

thanks @martinklepsch, good to know

benzen12:09:48

About devcards with reagent Is there anything special do to on a component that has an internal state (what reframe calls a form-2 https://github.com/Day8/re-frame/wiki/Creating-Reagent-Components#form-2--a-function-returning-a-function)

danielgrosse13:09:44

Beginner Question. Whats the difference between #()and ()? e.g. #(swap! atom inc)

jgdavey13:09:01

@danielgrosse: The first #() form returns a function, whereas the second () actually calls functions.

danielgrosse13:09:52

@jgdavey: okay thanks. Thats declares it. When I return a function, how is it called?

jgdavey13:09:53

In your example, (swap! atom inc) would call swap! with the arguments

jgdavey13:09:38

But #(swap! atom inc) would return a function. It’s really just shorthand for (fn [] (swap! atom inc))

jgdavey13:09:49

You can call a function by putting it in the “call” position, that is, putting the first in a list: (let [my-fn #(println “Hello”)] (my-fn))

danielgrosse13:09:05

Okay. Thank you.

Pablo Fernandez15:09:35

Can cljsbuild/cljs compile clojurescript to run by nodejs with projectx/target as the root directory? That is, to generate paths relative to projectx/target/ and not prejectx?

Pablo Fernandez15:09:27

Essentially, trying to fix this:

Pablo Fernandez15:09:37

fs.js:500
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^
Error: ENOENT, no such file or directory 'target/server-side/react.inc.js'
    at Error (native)
    at Object.fs.openSync (fs.js:500:18)
    at Object.fs.readFileSync (fs.js:352:15)
    at Object.nodeGlobalRequire (/Users/pupeno/Projects/ninjatools/target/server-side/goog/bootstrap/nodejs.js:85:26)
    at Object.cljs$core$load_file [as load_file] (/Users/pupeno/Projects/ninjatools/target/server-side/cljs/core.js:305:13)
    at Object.<anonymous> (/Users/pupeno/Projects/ninjatools/target/server-side/reagent/core.js:8:11)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)

csmith15:09:28

I wonder if it wouldn’t be possible and simpler to tweak a NODE_PATH environment variable or similar, to just add the target folder cljs builds to to the path node will use

hkjels16:09:27

Hi! Anyone familiar with secretary? I’ve got a few routes:

(defroute "/workspaces" []
    (dispatch [:set-active-panel :workspaces-panel]))

  (defroute "/workspaces/:workspace" [workspace]
    (dispatch [:set-workspace workspace])
    (dispatch [:set-active-panel :projects-panel]))

  (defroute "workspaces/:workspace/:project" [workspace project]
    (dispatch [:set-workspace workspace])
    (dispatch [:set-project project])
    (dispatch [:set-active-panel :project-panel]))
whereas the first two works fine, but the last one is not reacting at all. Any ideas?

esdee16:09:23

missing “/“ in the start of the last route?

hkjels17:09:21

Man!! I’ve looked at it a dusin times for typos without spotting that one. Thank you!

vorob17:09:30

Does anybody know why input won’t change itself if I remove fn [] ?

(defn new-contact []
  (let [val (r/atom "")]
    (fn []
      [:div
       [:input {:type "text"
                :placeholder "Contact Name"
                :value @val
                :on-change #(reset! val (-> % .-target .-value))}]
       [:button {:on-click #(when-let [c (parse-contact @val)]
                              (add-contact! c)
                              (reset! val ""))}
        "Add"]])))

staypufd17:09:00

I have a newbie type question about Om and how to use buttons to cause another sibling view to switch out. I was thinking I could use shared state but that seems global to the app. Is there a way to put the state in the containing component and then still get to it without passing it in all over? The page looks like:

staypufd17:09:06

navbar across top, then buttons down side in there own div section the is 1/4 of grid, then another div for middle and right of screen. When a button is clicked on left, I want to set state and then react to that and switch out middle

staypufd17:09:20

any help would be appreciated as I”m a noob to OM

voytech17:09:49

@vorob I think calling new-contact should be assumed to return function - I think result of call (new-contact) should be function composed with other functions to build DOM dynamically at the end... when you return this vector html structure just as it is the outer scope (where the atom is) will be not accessible as it is then only like lexical scope in new-contact function, but when You return function (which is using atom in function body) you are taking with You this outer scope ( atom ) because function needs to depend on it.

vorob17:09:19

@voytech: @hkjels thnx so much:thumbsup::thumbsup::thumbsup::thumbsup::thumbsup:

scriptor20:09:25

hi everyone, having an issue with om, particularly om/update!

scriptor20:09:38

I'm calling it on an atom to update a particular cursor

scriptor20:09:51

(om/update! root [idx k] {})

scriptor20:09:08

so it should be set to {}, if I understand correctly

scriptor20:09:59

however, when right after I use (get-in root [idx k]), I get nil

scriptor20:09:14

is it possible that the call to update! is asyncrhonous

mbertheau20:09:03

What are advantages of om when compared to reagent?

dnolen20:09:43

@scriptor writing and reading immediately from a cursor isn’t an encouraged thing. (get-in @root …) might work.

dnolen20:09:04

@mbertheau: Om provides zero sugar for markup generation, you can sugar to taste. Also it’s very opinionated about modeling the application around a single atom.

dnolen20:09:24

@scriptor: @mbertheau: there’s also a decently active #C06DT2YSY channel here

wambat21:09:51

Hi all! Have anyone tried to chunk 'defmethods' for 'defmulti' in different namespaces? I've tried require :refer form, without success. Or is it considered a bad practice for some reason?

danielcompton21:09:19

@wambat: are you trying to create multimethod implementations for a multimethod defined in another namespace? That should work fine

danielcompton21:09:44

(ns example.ns1)

(defmulti handle-ws-event first)
(ns example.ns2
  (:require [example.ns1 :as ns1])

(defmethod ns1/handle-ws-event :error-event
  [params]
  (println params))

wambat21:09:55

Nice tip, i'll try it. Thanks, @danielcompton