Fork me on GitHub
#hoplon
<
2016-11-04
>
thedavidmeister05:11:40

@dm3 actually, now that i removed when-dom there is no timeout needed for the events to update the hoplon elements

thedavidmeister05:11:15

(deftest bind-events
  (let [c (j/cell nil)
        f #(reset! c true)
        i (h/div :click f)
        e (js/Event. "click")]
    (is (nil? @c))
    (.dispatchEvent i e)
    (is (= true @c))))

dm309:11:07

and if you do .trigger?

dm310:11:14

that's interesting đŸ™‚ where are you running the test?

dm310:11:11

so it's synchronous...

thedavidmeister10:11:28

i suppose the difference between an event you programatically trigger

thedavidmeister10:11:34

vs an incoming event from the browser

dm310:11:57

I can't find any definitive list of which events are synchronous vs asynchronous

thedavidmeister11:11:52

yeah that’s pretty vague

micha12:11:42

the with-init! changes i think are causing this issue

micha12:11:59

notice the settimeout there

micha12:11:33

that setTimeout 0 ensures that the fn is called after the dom has been built and all hoplon elements from the initial page load are in the dom etc

micha12:11:56

the browser's "load" events are more or less irrelevant to hoplon apps

micha13:11:07

because hoplon apps do not load their dom from html

micha13:11:32

in fact, hoplon blows away anything that's in the dom from html and then recreates it via js

micha13:11:36

i think we probably want to get rid of any of the loading things except for on-page-load which is a custom event related to boot-reload