Fork me on GitHub
#hoplon
<
2016-03-17
>
lhahn01:03:09

Hey, I am thinking about using hoplon for the client side of a side project. Does anyone know where does hoplon stand in terms of speed compared to other alternatives? (reagent, om, react)

micha01:03:39

we've built large applications with it, and speed was not a problem

lhahn01:03:15

cool, I was curious because from what I know hoplon does not use virtual-dom

micha01:03:00

hoplon doesn't need one, because javelin doesn't propagate unnecessary changes at the data layer

micha01:03:30

so it just naturally performs the minimum number of dom manipulations, whithout any need for things like that

lhahn02:03:02

nice, thanks for the help

thedavidmeister08:03:31

@flyboarder: thanks! will investigate simple_smile

thedavidmeister08:03:36

so, i turned my 2 pages (index and styleguide) into two defelem

thedavidmeister08:03:47

(u/outer-dom
  (u/the-header)
  (cell= (if is-index
            (index/index)
            (style-guide/style-guide))))

thedavidmeister08:03:07

I’m getting some serious negative performance issues (looks like garbage collection maybe?)

thedavidmeister08:03:30

but i see the issues even when is-index is not changing (the URL fragment is not changing)

thedavidmeister08:03:49

I think I don’t understand something >.<

thedavidmeister08:03:29

speaking to what @micha said earlier: "hoplon doesn't need one, because javelin doesn't propagate unnecessary changes at the data layer"

thedavidmeister08:03:50

I had thought that the cell= would have zero performance impact as long as is-index does not change

thedavidmeister09:03:02

the problem is probably me 😉

thedavidmeister09:03:22

ok, i think the problem was actually my crazy pseudo-route-cell

thedavidmeister09:03:14

nope, swapped to route cell

thedavidmeister09:03:17

still seeing it 😞

dm311:03:45

I used :toggle to "switch" between pages

dm311:03:06

or rather views in a SPA

thedavidmeister11:03:33

@dm3: that’s a nice tip for handling display

thedavidmeister11:03:45

i’m still not quite sure why it’s needed though

dm311:03:53

not sure either

dm311:03:37

thinking about it - it's idiomatic in react world to just do if this a() else b()

dm311:03:03

and it will remove the elements from DOM after diffing if the the condition changes

thedavidmeister11:03:26

i saw there is a PR up for an if-tpl

thedavidmeister11:03:30

no idea if that helps

dm311:03:04

ah, yes, if-tpl would be the proper way to do an if that depended on a cell

dm311:03:22

as you are returning a cell of dom elements to outer-dom

dm311:03:37

I'm confused why it even renders for you

thedavidmeister11:03:15

well i guess i’ll do a short writeup of my experiences on that PR then

thedavidmeister11:03:17

hey, does hoplon have a way to handle delegation of events to elements outside a loop-tpl?

alandipert11:03:29

a cell in scope for both elements is a way

alandipert11:03:56

you mean like, i click on something in the loop-tpl, and you want that to cause something to happen outside the loop-tpl?

thedavidmeister11:03:18

i mean like, i have 100 elements created by the loop-tpl

thedavidmeister11:03:25

and each one has 5 event handlers

thedavidmeister11:03:39

in jquery i can just delegate one event handler to an ancestor

thedavidmeister11:03:43

rather than have 500 event handlers

alandipert11:03:42

is 500 event handlers slow? or do you find delegating events cleaner

thedavidmeister11:03:18

i’m in the habit of delegating

thedavidmeister11:03:44

i don’t know what is slow though @alandipert

thedavidmeister11:03:52

something was slow

thedavidmeister11:03:04

and inconsistently too, which made me think of gc

dm311:03:18

you should see that in devtools profile

dm311:03:27

pretty easily

thedavidmeister11:03:04

well, when i profiled, it said it spent most of its time in jquery event adding

thedavidmeister11:03:17

i should have ss

alandipert11:03:34

definitely good to find what's slow and work from there

thedavidmeister11:03:19

for now i’m going to go with display:none;

thedavidmeister11:03:37

but i’m going to keep an eye on if-tpl and try again if/when that gets in simple_smile

leontalbot15:03:10

Hello @alandipert. I finally got the chance to test form validation with formula, and couldn't make it work. Here is what I have :

leontalbot15:03:40

I can't turn is-form-valid? to true

leontalbot15:03:29

seems to have a problem with form-postal-valid?

leontalbot15:03:04

problem solved. Made a typo somewhere else in my code

leontalbot15:03:13

Thanks again for make-validator!

flyboarder15:03:11

@thedavidmeister: I would also recommend sticking with :toggle for now, i believe there is also a cond-tpl in the works, which is probably more along the lines of cell based app views, im currently using a regex match over route-cell to handle nested views

alandipert16:03:32

@leontalbot: saw just ni time to also see you fixed :thumbsup:

micha16:03:35

the if-tpl macro uses the same mechanism as you're currently using with :toggle, except it removes things from the dom instead of hiding them

micha16:03:04

it doesn't do anything different with event handlers or anything

micha16:03:45

@thedavidmeister: you could use delegated handlers in loop-tpl, no?

micha16:03:51

why wouldn't that work?

dm317:03:01

@micha: should the snippet @thedavidmeister posted on https://clojurians.slack.com/archives/hoplon/p1458204887000228 work at all? Having a Cell of DOM elements passed as children to another element?

micha17:03:40

yes but then you are destroying and rebuilding that thing every time

micha17:03:56

so you need to manage memory then, or make sure the thing in the cell is a pure function

micha17:03:14

loop-tpl avoids all that complexity by using a pool of elements

dm317:03:08

yep, thanks

dm317:03:14

guess that was his problem

micha17:03:44

the cell= method will remove the children from the dom, but it can't make sure they get garbage collected

micha17:03:00

you'd need to do that manually if you have stateful things in there

dm317:03:03

this would be a Hoplon anti-pattern then simple_smile

dm317:03:17

too easy to generate garbage

micha17:03:47

yeah i avoid it wherever possible

jjttjj18:03:32

hey guys how's this sound for a pattern for a hoplon app that uses sente to do a lot of WS communication. Basically I'm sending a of messages to the server, most of which are responded to asynchronously. I have a 3 cells that are just lists of events: incoming-messages on which all incoming messages are conj'd, outgoing-messages, which messages are conj'd onto, and then a formula cell actually sends them to the server, and then user-inputs, a list of all user-input events. Then all ui components take as arguments formula cells that are some subset of these event streams, ie it will filter the incoming messages to just what it needs to display, and also take the actual event stream cells they may need to add an event to.

jjttjj18:03:34

It's working ok so far I think, but my home-brewed architecture ideas have not generally worked great in the past so i worry a bit 😛

dm320:03:03

seems like it should work, I'm doing something conceptually similar but not through cells