Fork me on GitHub
#hoplon
<
2015-09-19
>
flyboarder01:09:36

@micha: how are .hl files compiled in things like hoplon/twitter-bootstrap when i tried doing that it couldnt find the namespaces, i resorted to compiling the hl->cljs but that seems bad

mynomoto02:09:57

@flyboarder: on the latest hoplon (alpha10) you need to add a :manifest true on the hoplon task before doing the build-jar. The .hl files will be compiled when used on other projects by the hoplon task.

mynomoto02:09:24

This on the library. On the project that will use it you don't need the manifest option.

mynomoto02:09:38

*this is on the library...

flyboarder02:09:18

awesome thanks!

tbrooke13:09:17

I know I’m a minority here with vim but it would be nice to have a vim-hoplon plugin with hl highlighting If I had time and if I was better with plugins I’d write one 😁

micha13:09:24

it's not perfect but that combined with some lispwords setttings does an ok job of things

tbrooke13:09:05

@micha Duuh just realized it’s just either cljs or html but using your autocmd so I don’t have to type set filetype=clojure Thanks

mynomoto14:09:43

@micha: what do you think about having dependencies in each of the demos instead of the current schema of centralized deps? It will be more beginner friendly imo.

micha14:09:13

we can now make a boot task to help manage that if we want to

micha14:09:57

like a task we run on the repo to update deps

mynomoto14:09:55

Yeah, I probably would still use grep, but we could do it 😉

micha14:09:12

haha if grep works then go with that

piotrek19:09:26

Hi, I'm playing with hoplon and hlisp

piotrek19:09:28

I am wondering what is hoplon's equivalent of ng-if based on the cell's content

piotrek19:09:35

Is there any?

micha19:09:21

what is ng-if exactly?

piotrek19:09:07

Based on the condition it removes or adds an HTML child element

micha19:09:42

we generally use the equivalent of ngHide

micha19:09:52

but you can do something like this:

micha19:09:38

(defn ng-if
  [show? child]
  (cell= (if show? [child] [])))

micha19:09:47

then in your program you can do

piotrek19:09:55

Sometimes (e. g. If the sub tree is big and for performance reasons) ng-if is better than ng-hide

micha19:09:17

(div :class "container" (ng-if some-cell (span "foop")))

piotrek19:09:38

@micha wow so simple

micha19:09:43

this does not deallocate the thing it's removing from the dom though

micha19:09:05

it keeps a reference to it and just shuffles it in and out of the dom

micha19:09:34

if you're going to want to dynamically deallocate you will need to hand craft things, because js doesn't have weakrefs

micha19:09:46

so you're likely to end up with memory leaks unless you manually clean up

micha19:09:09

we generally try to organize our applications so we don't need to do this

piotrek19:09:10

I guess I could pass a function which would generate child element instead of the element

micha19:09:35

yeah but if that child element will hold references to things you could end up never actually deallocating them

piotrek19:09:02

Thanks for the info

micha19:09:11

if you have dom elements that have no state, meaning they're not being refered to by any closures etc

micha19:09:18

you can just do the cell= thing like this:

micha19:09:59

(div :class "container" (cell= (for [text seq-data] (span text)))

piotrek19:09:08

BTW new hoplon site and doc seems like a work in progress

micha19:09:13

where seq-data is some cell containing a seq of strings for example

micha19:09:25

thta will completely deallocate and reallocate

micha19:09:32

similar to react really

piotrek19:09:36

Do you have any ETA when it will have the basic info?

micha19:09:47

including a sort of dom diffing

micha19:09:14

it's a community effort, so we don't have a strict ETA

micha19:09:29

things are progressing very well i think

micha19:09:42

in a few weeks or months things should be well settled i think

piotrek19:09:37

Yes, your example with seq-data will work for me

micha19:09:08

just watch out for leaks simple_smile

micha19:09:58

we're thinking about ways to make cleanup easier, without resorting to lifecycle protocols

micha19:09:10

more like with-open than IDidMount

micha19:09:59

so you can use the seq-data way with more complex stateful custom elements that need to allocate cells internally etc.

piotrek19:09:28

I saw your presentation on clojutre conference where you compared hoplon approach to react (among others) like virtual DOM, life cycle etc

piotrek19:09:02

Can you point me to more details why hoplon approach is better?

micha20:09:26

there isn't a lot of documentation there

micha20:09:34

but the benefit is simplicity

micha20:09:53

react is complicated and sort of incidental complexity

micha20:09:42

pretending the dom is stateless involves all kinds of doublethink

micha20:09:07

the dom isn't stateless, and nobody wants a stateless dom

micha20:09:21

stateless dom is called <canvas>

micha20:09:05

and canvas isn't the thing you want to make webapps in, unless it's something very specialized

micha20:09:33

react is an immediate-mode rendering machine

micha20:09:49

but it's an API inversion, because the DOM is retained-mode

micha20:09:00

Document Object Model

micha20:09:44

in games like Doom or whatever you can make immediate mode rendering on top of pixels, because pixels are simple stateless write-only registers, basically

micha20:09:12

once your pixels can be interacted with by the user and contain their own state it's no longer immediate mode

micha20:09:57

this API inversion is why you need all the lifecycle protocols

micha20:09:05

and how to lifecycles compose?

micha20:09:16

they don't, really

micha20:09:43

lke you have IWillMount and stuff

piotrek20:09:51

Now it is more clear to me what you meant and it makes sense

micha20:09:04

but you start really trying to make composable things and you end up needing IBeforeWillMount

micha20:09:12

and IBeforeBeforeWillMount

micha20:09:14

and so on

micha20:09:25

because the lifecycle things happen asynchronously

micha20:09:35

you can't just compose functions anymore

micha20:09:52

lisp itself has "lifecycle protocols", but it's not something you really think about

micha20:09:07

it's done by composing functions and calling functions in a certain order

micha20:09:30

not by creating all the things in your lisp program in some map and then asynchronously calling lifecycle protocols on them

piotrek20:09:32

Hoplon looks very promising to me and I just can't wait for more documentation ☺️

micha20:09:53

like imagine if functions needed IWillBeApplied and IWasApplied etc

micha20:09:59

it would be madness

micha20:09:37

basically any time i see any kind of lifecycle protocol i suspect shenanigans

piotrek20:09:49

One last question

piotrek20:09:58

What's the difference between class and do-class in hoplon?

piotrek20:09:59

I saw such convention in some examples

micha20:09:56

the :do-* and :on-* idiom has actually been removed

micha20:09:05

now it's just :class

micha20:09:37

that was an artifact from the beginning that we found wasn't really necessary

piotrek20:09:37

Oh so I saw some outdated examples

piotrek20:09:57

Thanks a lot for all the answers

micha20:09:57

yeah we're updating them

micha20:09:02

sure any time