Fork me on GitHub
#hoplon
<
2016-02-08
>
laforge4902:02:42

[ANN] release: aaworker version 0.1.0. Dropped async.core, added worker notifications, added ! to the end of the names of funchtions which alter state.

laforge4902:02:26

The tworker demo in hoplon/demos has also been enhanced to exercise all the features of aaworker

laforge4902:02:13

My plan for tomorrow--start working on integrating hoplon and indexedDB. Wish me luck, @micha

micha02:02:30

via con juevos amigo

laforge4903:02:30

not finding any translation

micha04:02:20

good luck!

leontalbot15:02:48

Hello! I get stuck with having my app working in .html.hl

leontalbot15:02:29

So I tested with the hoplon readme simplest example. https://github.com/hoplon/hoplon#example index.cljs.hl works, but not index.html.hl

leontalbot15:02:37

No console error

leontalbot15:02:53

Any clue where I should look to try to make it work?

leontalbot15:02:57

Much thanks!

micha15:02:08

hm, can you look at the cljs file it generates?

leontalbot15:02:57

So @micha, where can I find it?

leontalbot15:02:20

target/index1.html.out/??

micha15:02:24

it's in app_pages

leontalbot15:02:45

in target/index1.html.out/hoplon/app_pages I got a .js file

micha15:02:19

hm one sec

micha15:02:10

so i just ran the lein new hoplon foop thing

micha15:02:44

when i build it (i added the target task so it writes to a directory) i can see the file target/index.html.out/hoplon/app_pages/_index_DOT_html.cljs

micha15:02:53

that's the one

dm315:02:20

I assume javelin formula cells only propagate updates if the content doesn't match using =, is that right? E.g. if a root cell changes, and the formula cell recomputes to the same result, no further updates will be triggered.

leontalbot15:02:37

Ok, now I got the cljs file @micha

micha15:02:14

so that looks more or less legit there

leontalbot15:02:23

So when I click "click me" the clicks cell doesn't update...

leontalbot15:02:43

only with the .html.hl version...

micha15:02:56

i would inspect the cljs file there

micha15:02:01

and try to see what's different

micha15:02:30

it could be some typo in the html perhaps

micha15:02:46

it's easy to have mismatched tags or something and not see it

micha15:02:56

when you've been staring at it for an hour

micha15:02:29

so the first thing i would do is either enable pretty printing in the hoplon compiler

micha15:02:47

or in this case the page cljs code is small so just manually indent it

micha15:02:56

so you can see if something was nesting incorrectly

micha15:02:02

that's probably where you'll find the issue

micha15:02:32

oh i see, you have :on-click there

micha15:02:37

that's no longer supported

micha15:02:45

what if you change that to just :click?

leontalbot16:02:41

in the html?

leontalbot16:02:22

lol, it works!

micha16:02:00

👍 sweet!

laforge4916:02:29

so https://github.com/hoplon/hoplon#example is no longer supported, or perhaps just out of date.

leontalbot16:02:20

thanks @micha! I might have I suggestion here: for .html.hl files maybe we should respect a bit more html names so that instead of going <html-meta> I use only <meta> and I use cljs-meta in the hoplon script on top when needed (rarely I guess). Same for keeping on-click attribute. That way I could use directly the designer's code without trying to adapt it. Would that make sense?

micha16:02:02

sure, what you can do is this:

laforge4916:02:32

So is this correct? <button :click="{{ #(swap! clicks inc) }}">click me</button>

laforge4916:02:47

or this? <button :click "{{ #(swap! clicks inc) }}">click me</button>

laforge4916:02:56

(I suspect the latter)

laforge4916:02:12

I'll fix it then.

leontalbot16:02:19

<button click="{{ #(swap! clicks inc) }}">click me</button>

micha16:02:31

<script type="text/hoplon">
  (page "index.html"
    (:refer-clojure :exclude [meta]))
     
  (def meta html-meta)
</script>

micha16:02:56

we don't want to globally clobber the cljs.core/meta i don't think

micha16:02:04

at least not by default

leontalbot16:02:04

yes, makes sense!!

leontalbot16:02:39

how about a way to keep on-click?

micha16:02:02

we did support it for a long time, but for 6.0.0 we remove it for performance reasons

micha16:02:34

in reality that might not be a big enough improvement to justify removing the feature

micha16:02:46

i didn't think anyone was using that

leontalbot16:02:52

@micha LOL! I guess I do simple_smile

micha16:02:50

i was trying to streamline the initial page loading

leontalbot16:02:07

yes, important too

micha16:02:08

removing support for the :on- variants eliminates one step

micha16:02:18

that would have to be done for every attribute

micha16:02:39

but it's only a string comparison which should be super fast

micha16:02:44

so maybe it was premature

laforge4916:02:28

I'll fix my error

leontalbot16:02:35

@micha in .cljs.hl files not sure, but in html.hlfiles I see a "benefit" to stick to "on-". I mean, if you use html.hl files, it's probably because you depend on a designer who doesn't know about clojure

micha16:02:24

but on-click isn't a standard attribute either

leontalbot16:02:33

onclick right

micha16:02:44

you don't want to use attributes i don't think, because i think they're not the same on different browsers

leontalbot16:02:43

so how would look our example ideally?

leontalbot16:02:50

(btw, I think we should stick to click then and forget the "on-")

micha16:02:07

something like that?

leontalbot16:02:18

Yeah ok. So click is an arbitrary attribute in the html world, but a convention for hoplon apps.

leontalbot16:02:13

that's fine with me

leontalbot16:02:29

sorry for the noise

leontalbot16:02:16

and thanks for the (def meta html-meta) trick!

micha16:02:59

it's not actually a convention in hoplon

micha16:02:42

when you have an attribute whose value is a function the hoplon implementation interprets that as an event handler

micha16:02:51

and the name of the event is the attribute name

micha16:02:06

because generally it makes no sense to set an html element attribute to a function value

micha16:02:12

so it's not ambiguous

micha16:02:36

so event names, like click in this case, are handled by the on! multimethod

micha16:02:58

if you wanted to make a custom event doit you could do this

micha16:02:09

(on! :doit [elem attr-name callback]
  (.on (js/jQuery elem) "doit" callback))

micha16:02:35

that would use jQuery to set an event handler for the custom doit event

micha16:02:47

this is in fact the default behavior

micha16:02:18

here is the default multimethod dispatch:

micha16:02:05

so what's happening is that there is no click handler defined in hoplon anywhere

micha16:02:19

but the default handler falls back to just setting a thing with jQuery

micha16:02:38

and jQuery itself supports an event named click by default

micha16:02:55

so the convention is established by jQuery in this case

leontalbot17:02:18

On an other subject, I am no trying to figure out how I can write partial views of my app in html

leontalbot17:02:11

The example I find use (defelem ...) and the views always seems to be written in hlisp

leontalbot17:02:46

Would it be a way (and is it a good idea?) to defines thoses vies in html (in a .html.hl file?)

micha17:02:09

that's where it starts to become less attractive to use html syntax

micha17:02:27

i think you really want to work on the custom elements in cljs syntax

micha17:02:41

but if you design them well they can be composed together very easily in html

micha17:02:08

we are lacking a good way to define simple composite things

micha17:02:21

which would be something to think about how to do

micha17:02:44

because yes the designer should be able to have a simple way do combine some elements to make a new element

leontalbot17:02:17

I was using enlive for another project, but it gets really complicated

leontalbot17:02:25

ok, if you need to test this kind of new feature, I can help out simple_smile

micha17:02:02

excellent!