Fork me on GitHub
#hoplon
<
2015-11-04
>
esp100:11:22

anyone using boot-reload with hoplon?

esp100:11:09

i’m trying to use it, but i’m getting lots of warnings like nav already refers to: mecha1.www.component.page/nav being replaced by: mecha1.www.component.page/navat line 31mecha1/www/component/page.cljs

micha00:11:08

@esp1: i think you want to do something like

micha00:11:25

(with-page-load (.reload js/location))

micha00:11:48

hoplon isn't able to hot patch the dom in place at the moment

esp100:11:00

i see, thx

micha00:11:10

those warnings are in the browser, right?

micha00:11:15

not in the cljs compiler?

micha00:11:18

oh ok yeah

micha00:11:40

although warnings aren't necessarily indicating a problem

esp100:11:58

well, dom isn’t updating either

micha00:11:01

i mean if you are using reload you want to replace those things

micha00:11:16

yeah you'd need to devise a way to do that

micha00:11:26

one thing i tried was like this:

micha00:11:02

`(defn render []

micha00:11:22

(defn render []
  (html
     ...

micha00:11:35

then below that

micha00:11:24

(defonce _ (do (render) (on-page-load (render)))

micha00:11:29

something like that

micha00:11:55

can you see what i'm getting at there?

micha00:11:26

i'm sure there is a slicker way to do it

micha00:11:41

but that might be a start anyway

esp100:11:36

if it’s only for dev, i was thinking maybe a :reload option to the hoplon task could stick in the requisite reload stuff into the page, which you could then leave out int the prod build

micha00:11:47

we could make a macro that emits all that stuff

micha00:11:22

(with-page
  (html
    (head ...

micha00:11:28

or something like that

micha00:11:39

it's inert if you're not in reload mode

micha00:11:46

so it's fine to have in production

micha00:11:18

on-page-load will only ever fire when boot-reload or other compatible reloader triggers the custom event

micha00:11:32

which won't happen in production, of course

micha00:11:40

so there's no issue there, i think

esp100:11:01

yeah, not a big deal, but having the task emit it allows you to elide the stuff entirely in prod, and also doesn’t require you to add extra stuff in your code. not a big deal either way, but more of a convenience thing i think

esp100:11:47

anyway thanks for the tips, i’ll rip out boot-reload for now and patch in js reload

micha00:11:50

in any case you'd need to put something in your code

micha00:11:08

you can use boot-reload

esp100:11:19

@micha btw, is it a goal of hoplon to allow hot-patching of the dom?

esp100:11:47

if so i’m wondering how you’d do that, other than by doing something like a virtual dom

esp100:11:50

(as an aside, i fixed my reload issue - apparently it didn’t like me having elements named nav and footer, so i renamed them and the warnings went away. weird)

micha01:11:12

i don't think it's a goal to do hot patching of the dom

micha01:11:28

but the same effect can be achieved other ways

micha01:11:40

like what i pasted above

esp101:11:58

well, that’s effectively rebuilding the entire dom isn’t it?

micha01:11:18

an implementation detail

micha01:11:27

of no consequence really

alandipert17:11:21

@esp1: i wonder if the nav/footer thing is related to the fact that dom nodes with IDs exist in JS as global vars

esp117:11:42

@alandipert: actually, those nodes don’t have ids. i just changed (defelem nav …) to (defelem m1-nav …) and the warnings disappeared. same story with footer. ¯\(ツ)

alandipert17:11:13

i think the problem is with hlisp functions

alandipert17:11:18

nav and footer are HTML5 elements

alandipert17:11:24

already defined in hoplon core

esp118:11:00

that would do it

micha18:11:29

(page "foo.html"
  (:refer-hoplon :exclude [nav footer]))

esp118:11:41

cool, thx simple_smile