This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-15
Channels
- # admin-announcements (10)
- # aws (2)
- # beginners (27)
- # boot (3)
- # cbus (4)
- # cider (1)
- # clara (6)
- # cljs-dev (3)
- # cljsrn (14)
- # clojure (98)
- # clojure-boston (1)
- # clojure-brasil (1)
- # clojure-czech (3)
- # clojure-dusseldorf (11)
- # clojure-greece (3)
- # clojure-japan (3)
- # clojure-korea (1)
- # clojure-russia (138)
- # clojure-uk (11)
- # clojurescript (76)
- # component (2)
- # core-matrix (1)
- # cursive (25)
- # data-science (3)
- # devcards (1)
- # euroclojure (4)
- # events (3)
- # funcool (1)
- # hoplon (219)
- # immutant (40)
- # juxt (8)
- # leiningen (1)
- # off-topic (34)
- # om (148)
- # onyx (10)
- # overtone (2)
- # proton (1)
- # re-frame (8)
- # reagent (3)
- # ring-swagger (5)
- # spacemacs (17)
- # untangled (47)
- # yada (19)
btw, i actually added :type "button" because the html5 reference i have says it must have a :type
@jouerose: it does, although if you want “hello world” to appear on the button itself, you need to do (button :type "button" :name "button-name" "hello world”)
. the value attribute in html is for use with submission mechanism of the enclosing form, i think.
@jumblerg: meanwhile i had just gone with an (input :type "button" :value "button-value") and "button-value" appeard on the button
by the way, there is something i have been wondering. why instead of js interop don't we have functions such as (get-element-by-id elem-id) ?
well, i’d argue that when building spas, esp with hoplon, we should avoid selectors entirely.
there’s no reason to go fishing around in the dom matching on strings when we can just bind to variables (who knows what you might scoop up in a global tag soup). this convention is madness, really, when you stop to think about it.
in hoplon, you have references to the elements in your code before they’re added to the dom. just work with those instead. much simpler. more performant. and you’ll actually get an error when something bad happens.
take a look at the examples, eg https://github.com/hoplon/demos/blob/master/castra-chat/src/hoplon/index.cljs.hl.
no worries. i think you’ll find this to be a far more sensible way of doing things once you become accustomed to it.
if you’re being handed an html document from a server, and you need to mutate it afterwards, then you might need a selector to pluck the node out of it you want to alter. but when you’re building an spa, you already have those elements, so you can reference them using vars/variables instead.
@micha: i managed to reproduce that bug from the other night in a minimal setup
just writing a test now to demo it
@thedavidmeister: it's so awesome having test cases
@micha: np at all
it’s hard to share/fix bugs without some basic tests
@micha hi. hope all is good. please let me know. if i do (.log js/console "something") , where does "something" appear ?
it will show up in the same place, the difference being that the clojure data is printed in a way that you can see it
@jouerose: and @micha, if I may butt in, I’ve found that (.log js/console)
is more useful for printing js data structures (like if you’re working with external js libraries like d3) and println
is more for clojure data
@levitanong: thanks for the hint
@levitanong: @jouerose i also made a little collection of macros for logging things: https://github.com/adzerk-oss/cljs-console
i only just realised today that I can do this (defn prnr [v] (prn v) v)
oooooh, cool @micha
and then not have to restructure my code every time i debug >.<
@micha @levitanong what would be your go-to method/way for http request in clojurescript if you are not using castra ?
anyway, i g2g for a bit
if someone could think of a way that :value
could tell the difference between two different cells with the same value, while i’m gone, that would be just amazing 😛
spy->
is what i’ve been looking for for a long time
@jouerose: if you're not sure which one you like i would recommend using jQuery because it's the best documented of any of them, and it's the best tested
so you are unlikely to run into browser compatibility bugs, and you can look on stack overflow for answers to any question you could ever imagine
jQuery is running on about 70% of all webistes on the internet, vs how many for cljs-ajax?
no plans to bundle cljs-console with hoplon currently, but we could if there is interest
@micha if it may encourage the bundling of cljs-console, i think the less we see/have to do interop, the better.
@micha no idea for cljs-ajax coverage. would you recommend "jayq" for jquery in clojurescript ?
@jouerose: here’s a snippet i wrote earlier this am you can use to get started:
(defc projects [])
(defn data [resp]
(-> (.parse js/JSON resp)
(js->clj :keywordize-keys true)))
(defn load-projects! [] (.get js/jQuery projects-url #(reset! projects (data %))))
that does all the stuff with setting Accepts and ContentType headers, parsing response body, etc
i like using jQuery for the cross-browser standardization layer just because any bugs will have been worked out already
whereas the google closure stuff is really only used by google, and not even in their main applications
Y0 @micha, @jouerose mentioned on #C03S1L9DN that you had made some interesting comments about goog.net.XhrIo here so I'm check them out 😛
I just want to confirm: http://goog.net should take care of all the cross-browser issues for me, like jQuery right?
and i just don't have time to maintain my own set of workarounds for different browsers
because out of the millions of sites that use jQuery someone will have already run into the issue and posted it on stack overflow
like i ran into issues doing something as simple as setting element attributes with goog closure
Gotcha, I guess I took it without question that Google Closure's libraries were solid because a number of ClojureScript people have spoken highly of the Closure compiler. I will definitely start considering individual projects for pieces that I'd otherwise use goog.* (like cljs-ajax).
Right, nobody wants to handle cross-browser stuff. I personally most likely won't be using jQuery but I will definitely look at reusing HTML5 and shims instead of relying on goog.* (e.g., before ClojureScript, I would use a fetch shim): https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API
So when I google "clojurescript web server", hoping for something like Ring or Express.js except in cljs for Node, hoplon comes up, but hoplon isn't quite Ring/Express right? It seems more than that
@fasiha: yeah hoplon isn't serverside cljs really
i know i've seen things, but don't know any offhand
I'm looking for options because I wrote this nice Clojure backend to talk to a ClojureScript frontend to run on the Raspberry Pi. But JVM & lein run
takes 2 minutes to start, whereas node.js starts in a second. So luckily I had prototyped most of the backend functionality in Node so I was planning on using a Node server, but thought to ask if Cljs+Node was an established thing or still experimental.
@fasiha: i remember seeing this experiment a while back https://github.com/seabre/matchcolor
@fasiha: cool, yeah. hoplon kind of relates to the server side in the sense that it can work with any backend. we built it originally on top of a php backend, and at this job it's on a clojure + mssql backend
Thanks @jumblerg between that and @bhauman's https://gist.github.com/bhauman/c63123a5c655d77c3e7f I think I can take a shot at it. Maybe there's not much chatter about express+cljs because it's so easy.
just got asked by someone here at work if there was a figwheel task for boot. if the perpetual recurrence of this word has taught me anything, it is that boot-reload needs a catchier name. 😬
ideally, something that completely obscures the semantics of the task in favor of the mysterious and magical.
people who have never written a line of clojure before start by asking me about figwheel
any suggestions for configuring Idea/Cursive for Boot and Hoplon files? I see that Colin intends to support them, but hasn’t gotten there yet
@jumblerg: i don't know of any, but I imagine there are differences in functionality on both ends
i feel like figwheel is more aggressive about macro reloading or something
its been like a year since i compared them myself
@jamieorc: re: cursive, there is stuff in the boot wiki about emitting project.clj from boot, which lets cursive at least see deps
@alandipert: thanks. I set that up, but still not seeing deps. I’ll have to see if I missed something.
hm, yeah. i bet cursive doesn't know about page
@jamieorc: i think @symbit has this process down, might be worthwhile to ping him direct, he could probably get you started.
hi all. is the use of the "(do ...)" form, a hint that may be i am not doing something well , or at least in the clojure/functional way .
like do
is a crucial construct. that's how lisp eliminates "statements" from the language
hey grant, welcome 👋
@cesarcastillo: hello btw! welcome
@jumblerg: I now see the dashboard. I am now ready to fire missile on flying @micha 😉
@jumblerg: So i'm in, but when I click on the red button, I get
core.cljs:264 Uncaught Error: No protocol method IStack.-pop defined for type cljs.core/PersistentArrayMap: {#uuid "2631d90a-eed4-4626-ad07-c4eb3c46b62c" {:fuze :vis, :warhead :nuke}, #uuid "caba4fe2-1589-4565-8e1c-d40a1fd29edb" {:fuze :vis, :warhead :nuke}}
this is where the problem happens (in the swap part)
(u/button hoplon.ui/+danger-button+ :w ["100%" sm 200] :h 50 :click #(swap! missiles pop) "Fire Missile")
@jumblerg: about routing, I would need to put more than one (u/window ...)
per page, I guess this is possible... Though actually, I get to see the two windows at the same time (side by side), whatever routing I pick...
Also, when I make a change, I see the new resulting windows is added to the right, but the old one stays there (until I hit browser's refresh button)
yeah, none of the controls are implemented yet. it is pretty straightforward from there though.
@jumblerg: yeah, np
regarding multiple window rendering, do you get the same behavior?
will do, thanks man!
oh, i think the two artifacts are stepping on each other in the build process; be back behind my laptop in 1/2 hour or so.
perfect!
@leontalbot: wrt multiple windows, i’ve never tried that, and no, that’s not the recommended approach for routing. you should have one window per artifact; the window component is merely your interface to the browser window. apologies, i misunderstood what you were doing earlier.
@jumblerg: Still have the problem when I change something in the code though
there are callbacks that fire on the window component when the route changes in the browser. similarly, you attach a cell to the query and route attributes that sets the path and query string in the browser.
the screenshot appears to show the TEST from your second window you added to the same file.
@jumblerg: yes, even with one window i get this when changing smth in the code:
@leontalbot try pulling the responsive-layout-attributes branch of hoplon now and boot build-jar
@jumblerg: regarding multiple-window per page, this would be really convenient for multiple pages website.
Because of the compilation time "issue":
http://hoplon.discoursehosting.net/t/structuring-a-multi-page-hoplon-application/489
with hoplon/ui offering this out of the box with be a great win.
this might be really naive though. I am just dreaming here
@jumblerg: I'm on it...
i’ll think about it. it is page
that is responsible for creating the artifact atm; the window component basically creates the html, head, and body elements for you in addition to creating interfaces to the browser.
ok...
gotta go, will test tonight
as best i can tell, hoplon already has support for multi-pages/“artifacts" per “site" such a thing is necessary. via the page declaration you can create as many pages as you like.
if you’re loading different pages, you need to reload whatever state each page requires back into memory from somewhere, most likely the server or maybe local storage. the advantage of an spa is that you can share state already in memory across all your views. it would be something of a shame to compromise the architecture of an application because of a development time tooling issue.
@jumblerg: True. I think the main issue with multiple page
s is compilation time. Multiple pages slows down reload and first load... so we get to a point we need to go with SPA. So how would work h/ui with SPA, only one window with a cell at :route
?
Is that where you want to go?
"it would be something of a shame to compromise the architecture of an application because of a development time tooling issue." Ok, gotcha