This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-09-05
Channels
- # bangalore-clj (4)
- # boot (196)
- # chestnut (1)
- # cider (4)
- # clara (3)
- # cljs-dev (23)
- # cljsjs (28)
- # cljsrn (1)
- # clojure (79)
- # clojure-art (1)
- # clojure-berlin (1)
- # clojure-hk (17)
- # clojure-italy (5)
- # clojure-korea (1)
- # clojure-russia (21)
- # clojure-spec (5)
- # clojure-uk (26)
- # clojurescript (125)
- # core-async (1)
- # cursive (23)
- # datomic (7)
- # emacs (17)
- # hoplon (51)
- # jobs (2)
- # leiningen (2)
- # om (11)
- # om-next (26)
- # onyx (39)
- # pedestal (9)
- # proton (4)
- # re-frame (43)
- # reagent (1)
- # ring (2)
- # slack-help (12)
- # sydney (4)
- # test-check (9)
- # yada (40)
@laforge49 I found the cheetsheet 🙂 this page has the jquery attributes listed at the bottom https://github.com/hoplon/hoplon/wiki/HTML-attributes-and-JS-events-%28on%21%2C-do%21%29
@flyboarder Looks like a start. What about things like :click? I suspect there are some patterns (onclick -> :click) which need to be covered, preferably by enumeration.
OK, it is covered in the same page under on!. My problem is that I don't know js, so I'd love to know all the attributes, including jquery attributes, which take function values. If I had a list, I could then look up things which might be useful for a given problem. As it is, I just stumble onto things and that makes it quite difficult.
@flyboarder Remember the problem I had with composing elements? I ended up with a solution, putting elements in a cell, which you warned me would lead to a memory leak. What I experienced was that the vector of elements in the cell kept growing and on reload my page was filling up with different versions of the elements.
Fixed that this morning. I'm doing a for-tpl over a vector of keywords and then using a multi-method to dispatch the appropriate element. Works very nicely and I no longer have dom elements in cells. 🙂
Here's where I call the multimethod: (div (for-tpl [capability login/capabilities] (login/add-element @capability)))
It is at the end of this file: https://github.com/tiples/welcome/blob/master/src/index.cljs.hl
@laforge49 you shouldn't dereference cells within *-tpl
macros because u break reactivity
if login/capabilities
is not a cell, then there is no point using for-tpl
though.
if you want to prepare for login/capabilities
becoming a cell later, then you should better code against it as if it would already be a cell and don't break reactivity by dereferencing within a loop
you should let hoplon dereference it either as attribute values or dom element children
Since I need the div in the driver code anyway, I can put the toggle there and simplify the components.
oh yes. so that hoplon could do the dereferencing. If I do the dereferencing myself, it works fine. Guess I must break one rule or another. Which is worse @onetom? @alandipert says having elements in cells leads to memory leaks.
if you use deref and then change login/capabilities
during runtime you will get surprising states as a result
Ah. but it does not change. So I'll switch back to that. But I do like having the toggle in the common code. 🙂
@laforge49: I wouldn't rely on a pattern which could cause problems just because your instance isn't having them ;) I fail to see why you need cells at all for your composition? Oh are building a list of elements correct? That can be done without cells, unless I am missing something
Ah yes. I could use an atom to do the composition. And stick the dereferenced atom into the div as the child.
I was getting multiple copies of the children with each reload, but I think if i switched to a map and then pulled out the values that would fix it.
The problem was that I was appending to a vector each time a namespace was reloaded, which meant that it kept growing. 😄
@laforge49: but using an atom is similar to using a cell, you just don't get the reactiveness of formula cells, I would try to avoid both of these for storing elements, regular immutable data structures should be ideal for this
I propose something like (-> [] (conj elem1) (conj elem2))
And build your list that way?
If you have a growing list on reload, it's caused by mutation, that would be a flag for me ;P
Yeah, I can't use a list or vector. But remember that the whole point is that composition is done without having to modify any code except for being sure that the component is referenced/compiled. So the only way I can see is with an atom or cell, Threading is out as it requires a piece of code that is knowledgeable of all the components.
@laforge49: I think you already solved it, the index page should know about all the components
Once you get it all working I'd be interested to see how it all went