Fork me on GitHub
#hoplon
<
2016-10-30
>
flyboarder00:10:44

@mynomoto: is there a repo somewhere?

flyboarder00:10:55

@mynomoto: can you try boot-hoplon 0.2.5 and/or hoplon-alpha15 then go from there?

flyboarder01:10:20

It might also be a problem with cljs 1.9.293 I can play with it soon just on mobile right now

mynomoto01:10:47

boot-hoplon 0.2.5 and hoplon alpha15 have the same problem. Am I the first to have this issue? That seems odd. I have to go now but will keep going back to see if I can find when this started. I haven't used boot-hoplon in a while, I was manually mounting without problems.

thedavidmeister01:10:42

is there a cell in hoplon core that tracks the viewport size?

jumblerg02:10:23

no. but you can easily make one, something like:

(defn resize-cell []
  (with-let [size (cell [])]
    (.addEventListener js/window "resize" #(reset! size (vector (.-innerWidth js/window) (.-innerHeight js/window))))))

jumblerg02:10:30

@thedavidmeister: consider that pseudocode, i've not tried it.

thedavidmeister02:10:31

@jumblerg looks good to me 🙂

thedavidmeister03:10:33

i went with a map, but the idea is the same

thedavidmeister03:10:36

(defn window-size
  []
  {:height (.-innerHeight js/window)
   :width  (.-innerWidth js/window)})

(defn size-cell
  []
  (let [c (j/cell (window-size))]
    (j/with-let [_ (j/cell= c)]
      (-> js/window
          (.addEventListener "resize" #(reset! c (window-size)))))))

jumblerg03:10:55

looks good too. if i wanted to use named values instead of positional coordinates i might stick the window object itself in the cell.

jumblerg03:10:50

call -innerWidth, -innerHeight in the next formula cell

thedavidmeister06:10:01

(defn size-cell
  []
  (let [c (j/cell js/window)]
    (j/with-let [_ (j/cell= { :height (.-innerHeight c)
                              :width  (.-innerWidth c)})]
      (-> js/window
          (.addEventListener "resize" #(reset! c js/window))))))

thedavidmeister06:10:43

didn’t seem to work

thedavidmeister06:10:18

i guess because (reset! c js/window) doesn’t make c equal to something new so it doesn’t propagate the value through the formula cells?

micha13:10:43

@thedavidmeister you can do like (j/cell [js/window 0])

micha13:10:00

then in the resize event listener you can do

micha13:10:33

#(swap! c update-in [1] inc)

mynomoto17:10:46

@flyboarder can reproduce the append on reload problem as far as hoplon alpha7 and boot-hoplon 0.1.5 and boot-reload 0.4.10, not sure of what else to test.

flyboarder17:10:24

I'll take another look

flyboarder18:10:19

@mynomoto I see the problem

flyboarder18:10:24

it's not the libraries

flyboarder18:10:28

it's the app

flyboarder18:10:13

So you can't reload a file that does (def myelem (hl/some-elem)) since the hlisp element returns a constructor you are actually creating the element again on reload, you want those to all be defn so the elements are only created when called within (html)

flyboarder18:10:41

does that make sense?

flyboarder18:10:11

I would recommend using defelem for those

mynomoto18:10:27

@flyboarder I don't think this is what's going on. This could cause some things disappearing from the old ones as it's stolen by the new thing appended. But whats being appended is not in a def, it's inlined.

flyboarder18:10:28

I don't think you want to inline like that, the elements are created outside of HTML block which isn't what you want

flyboarder18:10:16

@mynomoto yeah i got it working by changing all of the layout stuff and passing the kids through

mynomoto18:10:27

@flyboarder make everything a function worked, thanks.

mynomoto18:10:10

But this is related to the way things are getting mounted, I don't have that problem mounting manually.

flyboarder18:10:16

when you def the element is constructed (when the ns is loaded), when it's defn it's delayed until the fn is called

flyboarder18:10:01

so on subsequent reloads the element is already mounted somewhere, the new version then gets appended there

mynomoto18:10:19

Oh, now I understand. Also why I wasn't having this doing the mount manually. I will check how hoplon is mounting things later.