This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-06
Channels
- # beginners (3)
- # boot (2)
- # cljs-dev (11)
- # cljsrn (122)
- # clojars (9)
- # clojure (8)
- # clojure-austin (5)
- # clojure-korea (1)
- # clojure-russia (3)
- # clojure-spec (7)
- # clojure-uk (14)
- # clojurescript (45)
- # cursive (12)
- # emacs (7)
- # euroclojure (1)
- # hoplon (285)
- # instaparse (1)
- # klipse (37)
- # leiningen (1)
- # off-topic (3)
- # om (11)
- # onyx (4)
- # re-frame (5)
- # reagent (1)
- # sql (3)
- # uncomplicate (2)
- # untangled (17)
- # vim (5)
Hey guys, I just put together a presentation for the Toronto Clojure Meetup, it would be awesome if you can flip through it and let me know if I can improve on it anywhere, cheers!
https://prezi.com/dysx7w7boqrl/boot-hoplon/?utm_campaign=share&utm_medium=copy
Welcome! @sherbondy
hey @micha @alandipert any chance I could get a review of https://github.com/hoplon/hoplon/pull/154?
alpha17 doesn’t support deref on events?
@thedavidmeister are you using the jquery attr provider?
actually, i’m not using alpha17 because it’s not on clojars
i was just reading the code
(extend-type js/jQuery.Event
cljs.core/IDeref
(-deref [this] (-> this .-target js/jQuery .val)))
yeah it is
so what’s the way to keep using jQuery moving forward?
and is that OK, or is the plan to remove it someday?
so if you have a project using boot-hoplon using a version of hoplon before alpha17, you can upgrade to alpha17 with no changes
yeah i have boot hoplon
well yeah, as i’ve been finding today, getting events to propagate on detached DOM elements is fiddly without jQuery
so if for nothing other than testing, i want to keep it
also it is still being actively developed
so do i have to require hoplon.jquery
and hoplon.core
everywhere?
because that will get annoying
ok, yeah i do
when do you think alpha17 will be on clojars, so i can try it out?
oh cool
i don’t know why it was there in the first place
ok, well if you can remember what events they are
we can update the test easy
this is why test
#justsayin
mmm i know
neither do i
but if nobody can remember what it was for, that’s tricky
that could be good
also i definitely can confirm that different events bubble differently or not at all while detached in different browsers
I think we should be safe for the most part with the when-dom changes
and jquery events and native ones behave differently in that respect too
but i wouldn’t expect an event that you bind to a detached element to break when you add it to the document
that would be weird
The issue there is when an event is triggered before it's added not after, something's need the parent to exist
With the tests I believe
made it harder to test
because it means events don’t get bound until the element is added to the dom
so i have to manually add every element to the document before i can test it
i’m just testing the logic of my components
actually that is rendered in a browser
and looked at with selenium
that was hopefully to demonstrate to you that removing with-dom
does not break that case 🙂
https://github.com/hoplon/hoplon/pull/154/files#diff-34c2d91d36b80e7d4a953549243960f0R7
this bind-events
test is a very simple example of what i might want to test
that would not work with with-dom
well, partly the async and partly the explicit checking that the element is in the document before binding an event
both are inconvenient
well yeah, but i need to deal with async and attaching elements to the dom for every single test
well there’s no #container
but yeah...
more like (-> js/document .-body (.appendChild el)))
and also the async
i dunno, seems awkward to do this juggling for every single test shrug
well i just did this
(deftest bind-events
(let [c (j/cell nil)
f #(reset! c true)
i (h/div :click f)]
(-> js/document .-body (.appendChild i))
; Native event.
(is (nil? @c))
(.dispatchEvent i (js/Event. "click"))
(is (= true @c))))
doesn’t work because of async i think
yes but how do i avoid race conditions with with-dom
?
but why is that with-dom
on line 6 guaranteed to execute after the with-dom
from on!
?
but it loops
the first call is first, but if there’s a second call, who knows?
still not guaranteed, what if i get a garbage collection or something?
i mean, i’m running hundreds of tests that are all doing this
but then, i also add the overhead of all these timeouts to my tests 😕
like if you schedule a timeout and the thing is delayed, it will still execute them in order
yes that’s true
testing stuff is always going to be weird when you're doing unit tests and not integration tests
like with selenium you have integration tests, which are like making a normal application
but i either have to add like 100ms to every test, which will really slow things down
yeah i know, but my selenium tests are already clocking in at 10+ minutes and i’m nowhere near done with my app
and they’re getting flaky
and also, it’s very hard to directly measure some things, like the state of cells
yeah, if there’s an alternative that would be good
real shame we can’t remember what was broken in the first place 😞
but i was listening to your podcast from the other day, and one of you mentioned the two modes of developing with hoplon
“making the components” and “wiring everything up"
well it goes somewhere...
we have nodejs apps at work that are insane because of stuff they did to support testing
right now it goes into silly things i have to do for selenium to see 1/10th of what is actually happening
well… i can live with attaching all my dom elements manually before testing them if i have to
but i don’t want race conditions or arbitrary timeouts in the tests either 😕
actually that would be amazing
because i need that elsewhere other than tests
like for example, i have a js library that needs a canvas element to work on
I don't want to suggest life cycles or anything but maybe it would be good to emit events so elements act more like they were created from HTML
just knowing that something is “done being built” would be helpful
both for testing and working with 3rd party libs
but i do think that when we poll like in when-dom
we are introducing nondeterministic behavior
what about “hoplon core is done messing with this element”?
just in general there isn't a way for lisp programs to know much about what their end goal is
but it really is not fun to have to fall back to timeouts to hope an element is ready to pass off to a lib/test
i feel that if you extend hoplon with something that introduces async it’s up to you to manage that
but what hoplon ships with should be manageable “out of the box"
i do get what you’re saying about being able to change things dynamically
well you definitely shouldn't be making applications that depend on being able to order your event handlers via reflection
if you're running into race conditions with when-dom in your application i'd say you're doing something crazy and there is certainly a simpler way
like in tests you're exposing internals of different levels of abstraction and intermingling them
i probably could solve the lib problem using when-dom
but i am a bit concerned about “stacking” when-dom
when you call when-dom it creates that vector or adds a handler to it if it already exists
if you add a handler via when-dom when it's already in the dom it will do process.nextTick or whatever it is in the browser
i think that would be a good improvement
then i’d be willing to try your suggestion of wrapping the tests in when-dom
should i paste this conversation onto the github issue?
Browserify solved next tick already, maybe we can use this approach? http://timnew.me/blog/2014/06/23/process-nexttick-implementation-in-browser/
We can also skip their ie8 portion
I think we should move all the ie8 stuff to its own namespace otherwise we will have compatibility patches in core
But a fallback to set timeout is probably best
I'm sure it can be cleaned up as cljs in a smaller fashion
Would the event emitting not work?
like process.nextTick in node can be used to make an infinite loop that monopolizes the cpu forever
@micha: on an unrelated note, did you have a chance to look at the presentation I linked to? I'm just wondering if you see anything that's wrong 😜
aight im off
@micha: that is an interesting piece of machinery in #156
this presentation is prety slick @flyboarder
Thanks!
maybe I should show the cascading portion in another one
yeah perhaps a code demo there, show the whole (apply next-handler fileset)
as the result
ok, since the timing can be controlled and such
right
sounds good
actually that might be bad saying it returns middleware and returns a fileset
yeah the task itself returns middleware, and middleware returns a handler, and the handler returns a fileset
@flyboarder Do you have a code example with that slide? It may help a lot to understand what's going on if people can read code. I think I can only understand the slide because I'm already familiar with what that does.
yep, im presenting a demo of a freecodecamp react app that I converted to hoplon, thats a previous presentation
I mean of one boot task for the concept of middleware. But looking at your presentation it's a part too small to be able to give lots of details.
yeah the boot part is mostly an overview of whats going on, then it goes into hoplon with a bit more detail about the inner workings of that, followed by a visual app
the idea is to express that everything is usable on it's own, but cover the concepts which make it awesome to use together
Yeah, there is only so much one can explain with limited time. 😉 It's a really nice presentation. I always get a bit dizzy looking at prezi stuff lol.
yeah plus i dont want to spend too much time explaining and not demo
i think that makes sense, for the next person who decides to invent a new kind of cljs file.
it does seem that the boot-cljs task could take the initiative to clean this up, and encourage the user of a deps.edn
file or something with a depreciation notice when someone tries to ram a deps.cljs
file down the pipe.
maybe toss a few alerts at them for good measure, i see my old friend boot speak was generalized to do this.
^thoughts?
Which would let us replace the different ctors for SVG and factor out ie8 patches from core to its own ns
I also see this opening up to other frameworks creating hl compatible elements
Like jquery element for example
Then it's always a jquery element for the jquery provider instead of wrapping it each time
I think it would dispatch on the element itself when it's constructed
i dont know if that would work tho
Hello, I have a couple confusions about using hoplon/castra with multiple routes. I'm using the template from here https://github.com/tailrecursion/hoplon-castra-template and I want to have a /
route and a /comments/:id
route. So, I just copied the /
route and changed the route specification and the file name. However, when I navigate to /comments/0
or something, it doesn't seem to be able to find the new template.
Hmm, I think I figured it out, I had to put the complete path relative to the site root inside (page)
Now, I have to figure out how to pass data from defroutes into the template.