The :hoplon: ClojureScript Web Framework - http://hoplon.io/

When you associate a function to a input listener (e.g. the :input property of a hoplon/input), what is the type that comes in there? I'm getting an error trying to use that value and when I print what comes into my anonymous function, I get [object Event].

flyboarder 2017-12-28T02:22:31.000068Z

@jamesvickers19515 so are you providing a function to :input? Functions are for eventโ€™s. like :click

flyboarder 2017-12-28T02:23:20.000073Z

I assume you are wanting something like :change #(reset! some-cell @%)

flyboarder 2017-12-28T02:24:00.000017Z

remember you arnโ€™t reading from the DOM, you are responding to DOM events


Right, I'm trying to do a listener for an HTML input. I changed my handler function to be on :change instead of :input. My code looks something like this:

(def principal-input
    :id :principal :type "number" :min "1.00"
    :max "1000000000"
    :step "0.01" :value balance-cell :change #(reset! balance-cell @%)))
...where balance-cell is defined as a var bound to a javelin cell. But when I change the HTML input (e.g. click on up/down arrows), I get an error: Error: No protocol method IDeref.-deref defined for type object: [object Event]


I believe I did have it working at some point as an anonymous function on :input; does that seem surprising?

flyboarder 2017-12-28T03:20:41.000115Z

Im not familiar with the input event, I always use the changed event, are you including hoplon.jquery in your ns?

flyboarder 2017-12-28T03:21:16.000016Z

@jamesvickers19515 ^


@jamesvickers19515 #(.log js/console %) for debugging events - use the native console functionality or you just get useless JS object serialization logic


IDeref is implemented for events in hoplon.jquery so will not work until you include that ns as mentioned ^^


(extend-type js/jQuery.Event
  (-deref [this] (-> this .-target js/jQuery .val)))


you can see it's just a shortcut for calling $(this).target.val() so is entirely optional if you want to work against the event directly


@hiskennyness i sense a blog post coming on ๐Ÿ˜‰ sounds like you have experience on both sides of the fence


Thanks everyone; the problem was indeed that I wasn't including hoplon.jquery into my namespace. I recently removed that inclusion during refactoring, since there were no usages; I didn't realize it had implicit usages. As for :input vs :change, it looks like :change is fired when the value changes either by the arrow spinners or typing in a new value and pressing enter, while :input changes from arrow spinners and any keystroke into the input box.

flyboarder 2017-12-28T17:34:21.000183Z

@jamesvickers19515 the hoplon.jquery ns is what we call an attribute provider, it handles how attributes should be processed. Otherwise hoplon just uses the native js functionality. You can read more about them on the wiki: https://github.com/hoplon/hoplon/wiki/HTML-Attributes-and-JS-Events https://github.com/hoplon/hoplon/wiki/Attribute-Providers

kennytilton 2017-12-28T17:53:57.000223Z

Close! It will be a Clojure-NYC talk Jan 17, 2018: https://www.meetup.com/Clojure-NYC/ Not much React-bashing since I can just refer folks to thems that know more than I on existing web frameworks: https://www.infoq.com/articles/more-than-react-part-i and https://github.com/ThoughtWorksInc/Binding.scala and https://www.mendix.com/blog/making-react-reactive-pursuit-high-performing-easily-maintainable-react-apps/โ€ฆ what the MobX crew misses is that they do not need ReactJS anymore. The binding.scala effort and Hoplon/Javelin have that right.

kennytilton 2017-12-28T17:55:50.000070Z

Heh-heh, not sure I linked the above to @thedavidmeister very effectively. I blame #slack.


hiskennyness "fine-grained dataflow" i like it


Are there more examples out there for using hoplon.svg? Made a polyline plot from the example (`plotSVG`), wanting to add axes labels, tick marks, plot title, etc.

flyboarder 2017-12-28T21:53:42.000280Z

@jamesvickers19515 not really, there are special cases when it comes to SVG, like using :xlink/* and :svg/* attributes since jquery doesnt handle CamelCase attributes

flyboarder 2017-12-28T21:54:47.000196Z

it has been used previously tho

flyboarder 2017-12-28T21:55:25.000036Z

let us know when you run into issues so we can document it ๐Ÿ˜‰

flyboarder 2017-12-28T22:09:58.000194Z

Just updated the wiki homepage to make it look like itโ€™s actually a relevant place to go for information ๐Ÿ˜›


@flyboarder thanks, it seems kind of hard or tedious to do line charts with that svg library, think I'm gonna try http://thi.ng/geom


That came out wrong, my goal is to make 2D line charts and so I probably want something kind of tailored to that :)