Fork me on GitHub
#hoplon
<
2016-03-24
>
micha02:03:29

^^ i took a stab at some things there, macro transformations

thedavidmeister12:03:21

so i just noticed that (div :class {“foo” (cell= foo?)}) doesn’t update dynamically but (div :class (cell= {“foo” foo? })) does, is that correct?

micha12:03:57

yep, the attribute value needs to be a cell

micha12:03:26

the logic there needs to be very simple and not do any walking of the value or you could see performance issues at page load time

micha12:03:49

like if it has to walk every value looking for cells and then try to figure out how to make it into a cell

micha12:03:06

basically you can bind an attribute to a cell

micha12:03:09

or to a value

micha12:03:54

we want to minimize the amount of work that needs to be done to initialize and create new elements, which means simplifying the API there

micha12:03:44

this is especailly important in hoplon where you tend to allocate elements up front, statically

thedavidmeister12:03:27

i think that’s OK

thedavidmeister12:03:31

i just got the docs wrong

micha12:03:11

we could modify the :class do! method to do something special to accomodate that case, but then the API would depend on the do! method, which would probably be confusing

micha12:03:45

like currently the do! methods don't even know anything about cells

micha12:03:56

they're more like jquery plugin methods

micha12:03:09

they just operate on an element and arguments to mutate the element

micha12:03:26

and the cell stuff is hooked up automatically by hoplon where appropriate

micha12:03:05

for each attribute/value pair hoplon uses a simple case analysis to determine how to do it

micha12:03:29

1. if the value is a function then it calls the on! method for that attribute

micha12:03:57

2. if the value is a cell then it adds a watch to the value and calls the do! method for that attribute whenever the value cell changes

micha12:03:16

3. if the value is just a value it simply calls the do! method for that attribute

micha12:03:07

the idea is that there is no ambiguity there--the only sensible interpretation for an attribute whose value is a function is to set an event handler

micha12:03:14

i.e. on! method

thedavidmeister12:03:33

@micha: but i think it could benefit with some fact checking from someone more across the internals like yourself

thedavidmeister12:03:12

I missed the point about the distinction between cells and values in do!

thedavidmeister12:03:19

there might be some other important points

micha12:03:34

sweet, i'll have a look

thedavidmeister13:03:23

@micha: also, i think you need to toggle on the hoplon repo in travis for my PR to work simple_smile

thedavidmeister13:03:38

it was using my account on my fork

thedavidmeister13:03:46

but i don’t think that carries across

micha13:03:26

hmm, i wonder if travis has some way to allow organization access to an open source account?

thedavidmeister13:03:08

but i assume the free version lets all the repo admins access?

dm313:03:25

@micha - the conditional macros look great! Did you make them different from the loop-tpl on purpose? I recall loop-tpl has a :bindings argument in order to facilitate the HLisp calling convention and make it possible to use from HTML. Should the new macros also follow that route?

micha13:03:25

ok cool i think it's doing it

micha13:03:29

travis that is

micha13:03:54

the for= macro is a step away from the HTML syntax support

micha13:03:28

we could add in some argument parsing logic to support html attributes like loop-tpl, optionally

micha13:03:34

which would be the ideal thing

thedavidmeister13:03:43

you should see travis do stuff in github the next time a PR goes up, if it’s working simple_smile

micha13:03:00

but i'm not sure how many people actually use the HTML syntax, really

dm313:03:08

I think it's only you simple_smile

dm313:03:22

out of all the 20 Hoplon users

micha13:03:32

haha, i don't use it myself anymore

dm313:03:12

shall you release beta-1 soon?

micha13:03:27

yep i think we should

thedavidmeister13:03:22

@micha: yay! now we can start writing tests that could possibly fail simple_smile

micha13:03:26

yeah this is sweet

micha13:03:36

we can have any number of test pages, too

micha13:03:05

the test pages will be a nice set of feature demos

thedavidmeister13:03:03

yeah, i can put up PRs for clj and cljs testing too

thedavidmeister13:03:11

i’ve got all three in my project

thedavidmeister13:03:32

if you just want to test functions and not DOM behaviour

thedavidmeister13:03:20

but i was thinking of going through http://caniuse.com and comparing it against the HTML tag list

thedavidmeister13:03:29

for the first test

micha13:03:38

sounds legit to me

levitanong13:03:58

Hey guys, have you considered switching to gitter? https://gitter.im

levitanong13:03:42

All the public rooms have unlimited history, and I think a lot of the newcomers can benefit from the wealth of information.

levitanong13:03:00

(not that we have many newcomers 😛 )

micha13:03:20

interesting, yeah

micha13:03:33

slack has a somewhat shaky future i think

micha13:03:38

for open source projects

micha13:03:54

it's not clear what they intend to do with us

levitanong13:03:44

yup! In my company, one of the main reasons we hesitate switching to gitter is the fact that we have designers and marketing people who could benefit from the more agnostic approach of slack and hipchat.

thedavidmeister13:03:11

chat history retention is why we don’t use slack at work

thedavidmeister13:03:21

their paid plans are $$$

levitanong13:03:23

slack, for example, doesn’t require a github account

levitanong13:03:44

for something like hoplon that lives entirely in github, gitter makes a lot of sense.

thedavidmeister13:03:07

anyway, i gotta cruise

thedavidmeister13:03:11

see you all later

levitanong16:03:04

what’s up? simple_smile

raywillig16:03:08

@levitanong: thanks again for brainstorming yesterday. as usual defelem ftw

levitanong16:03:35

happy to help

raywillig16:03:35

so i was going through my project and realized I was changing every instance of (a … to (my-a

raywillig16:03:56

and then I thought, wouldn’t it make more sense to just redefine (a

raywillig16:03:31

but i have something like 15 namespaces that generate (a …. of one sort or another

raywillig16:03:11

so would I need to refer hoplon excluding a in every on of them and then require the thing that has the new (a in it?

levitanong16:03:38

if you do want to override (a), then I do believe you have to.

levitanong16:03:46

which i think might be more work than just renaming 😛

levitanong16:03:04

i think it’s safer to use (my-a)

raywillig16:03:10

especially cuz i’ve already renamed like 80% of them

levitanong16:03:27

you can also do a find-replace all

levitanong16:03:44

if you use the right regex, you can do it with the press of a button

raywillig16:03:43

and if i use the wrong one, i’ll give myself 5 hours of extra work lol

levitanong16:03:08

that looks about right!

levitanong16:03:35

omg it took me so long to figure out how to disable text wrapping in slack

levitanong16:03:41

so hard to read wrapped lisp code

levitanong16:03:26

out of curiosity, what IDE do you use?

dm316:03:50

the best editor

dm316:03:59

certified for Hoplon

dm316:03:01

and Boot

levitanong16:03:01

I've actually tried to go into vi, but I fell in love with Spacemacs' leader key. :p

micha16:03:03

i keep trying to use spacemacs, but every time i give up

micha16:03:30

i need something that works like vim-ctrlspace plugin

raywillig18:03:01

so for this project i’m working on my client would like the effect where i display some partial results and as the user scrolls down, i display another one or two rows of results anyone have any thoughts on the “hoplon” way to achieve this affect?

raywillig18:03:21

i’m look at youse @levitanong and @micha lol

micha18:03:38

thre are a couple of "infinite scrolling" demos

micha18:03:47

which seems like sort of what you want

micha18:03:59

canbe modified i think to do what you want exactly

raywillig18:03:03

oh that’s what that’s called? yeah that sounds exactly like what i want

raywillig18:03:12

i’m guessing in hoplon demos?

micha18:03:49

you should use the one that stores the scrolling state in the uri fragment probably

micha18:03:15

but i guess it depends on how your app is organized

micha18:03:32

that's just to make sure the back button doesn't make you start over from the beginning

raywillig18:03:33

sweet. I ❤️ this channel hoplon rox!

raywillig18:03:44

whoa @micha defc and defc= can accept doc strings?

micha18:03:09

should be able to, yeah

raywillig18:03:32

saw that in the demo. I never knew that.

roti19:03:00

I am trying to define a case-tpl function, and got stuck simple_smile

roti19:03:15

I am just about to give up, but I thought, maybe it's worth asking here

roti19:03:44

(defmacro case-tpl
          "Conditionally displays templates. Delays evaluation of templates until flow is determined."
          [value & clauses]
          `(case-tpl* ~value
                      (fn [v#]
                          (case v#
                                [email protected](apply concat
                                         (for [[value clause] (partition 2 clauses)]
                                              `(~value (fn [] ~clause))))
                                ))))

roti19:03:54

(defn case-tpl* [test-value case-fn]
      "Resets current with appropriate tpl from cache.
      cache is populated on demand, when tpl is not found for condition."
      (let [cache (atom {})]
           (with-let [current (with-meta (cell nil) {:preserve-event-handlers true})]
                     (do-watch test-value
                               (fn [_ t]
                                   (println "case-tpl*" t (case-fn t))
                                   (reset! current
                                           (cache-tpl-replace! cache t (case-fn t))))))))

roti19:03:28

and I get core.cljs:99 Uncaught TypeError: Failed to execute 'insertBefore' on 'Node': parameter 1 is not of type 'Node'.

micha20:03:54

might have some ideas you can use there

roti20:03:55

I wrote it after if-tpl

micha20:03:26

if you look at the case= macro you can see how it works

micha20:03:02

(defc c1 0)
(with-interval 1000 (swap! c1 inc))
(html
  (body
    (case= (cell= (mod c1 3))
      0 (h1 "0 mod 3")
      1 (h1 "1 mod 3")
      (h1 "other"))))

levitanong20:03:01

@raywillig: The server roundtrip would be unnecessarily high if you pulled the rows one at a time. I’d recommend you consider decoupling the per-row appearance, and the infinite scrolling.

levitanong20:03:06

For example, just before you reach the bottom of the page, you get an additional 20 rows, but don’t display them immediately.

levitanong20:03:26

@roti: You can also look at https://github.com/hoplon/hoplon/blob/master/src/hoplon/core.clj#L170 and https://github.com/hoplon/hoplon/blob/master/src/hoplon/core.cljs#L616 for something that uses cache-tpl-replace. I expect, however, that @micha’s implementation will supplant both if-tpl and switch-tpl soon.