This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-11-10
Channels
- # aws (45)
- # bangalore-clj (16)
- # beginners (109)
- # boot (137)
- # cider (7)
- # cljs-dev (54)
- # cljsrn (22)
- # clojure (77)
- # clojure-conj (1)
- # clojure-greece (2)
- # clojure-nl (5)
- # clojure-russia (36)
- # clojure-spec (15)
- # clojure-uk (54)
- # clojurescript (118)
- # cursive (7)
- # datomic (25)
- # emacs (33)
- # hoplon (276)
- # klipse (38)
- # lein-figwheel (1)
- # leiningen (9)
- # melbourne (1)
- # off-topic (18)
- # om (98)
- # onyx (6)
- # pedestal (1)
- # perun (24)
- # re-frame (46)
- # reagent (6)
- # ring-swagger (3)
- # spacemacs (67)
- # specter (15)
- # untangled (33)
- # vim (6)
Hey guys, I took a stab at the mk! multimethod, not sure how we feel about it, any thoughts?
The idea is that the mk! multimethod returns a function that is used as an element constructor
@flyboarder don't really wanna keep clogging the github up with my idiocy, but wait so it's not actually correct to pass to an element two consecutive sibling children unless they are in a vector or list? so
(div (p "a") (p "b"))
is wrong and should be (div [(p "a") (p "b")])
@jjttjj: it's not so much that it's wrong, more that it's different internal behavior
From your example tho usually you would use the vector form when you are building up a collection of children to display, your PR should solve this tho
@jumblerg there is a form *data*
binding problem if combined with if-tpl
:
(form
(text :key ...)
(if-tpl can-submit-yet?
(submit "GO" :submit js/console.debug)
(spinner)))
if can-submit-yet?
is false at creation time of the form
elem then the creation of the submit
elem would happen later when *data*
is not bound to the form's data cell anymore.do you have a recommended idiom to get around this? in hoplon i could just do
(submit :toggle can-submit-yet? ...)
(spinner :toggle (cell= (not can-submit-yet?)))
but there is no equivalent of :toggle
in hopon ui, or is there?
(i only found (bind-in! img [.-style .-display] :block)
in hoplon/ui.cljs
)
i got around it with:
(form
(text :key ...)
(let [submit-btn (submit "GO" :submit js/console.debug)]
(if-tpl can-submit-yet?
submit-btn
(spinner))))
but it's not helping understanding...Hmm but the visibility hidden doesn't take the element out of the layout so I can't use it instead of if-tpl, can I?
@onetom: in practice, from a ux perspective, i have found it more effective to disable buttons while preserving their position on the page until the required form fields are populated, so i haven't run into this particular issue myself. i don't like to shift the layout around by injecting elements like buttons into the view after some amount of validation has been completed.
certainly there might be cases where this scenario makes sense, however. dynamic binding often comes up short as a mechanism for propagating references from parents to children, even with micha's bound-fn implementation.
something like (elem :sh 300 :sv 60 :c (cell= (if is-complete :blue :grey)) :m :pointer :click #(when is-complete (dothedeed %)))
i've also changed up the form stuff a bit since the version you're using: https://github.com/hoplon/ui/blob/master/src/hoplon/ui.cljs#L632-L640
i've been experimenting with bubbling cells (on events) as a mechanism for setting up an inherited binding (inherited from parents as in css inheritance) scheme as an alterative to using dynamic vars for this. i'm not certain this is a good approach though; i really need to enumerate the various cases where there the dynamic variable model has caused issues to specify what a better abstraction for this might look like.
Yup, I've just started reading the latest formable source before I left the office. We would need to merge with our branch and see if anything breaks
@micha: incidentally, i was thinking about ns+
; i wonder if it would make sense to do away with this in favor of a simple ns
in a .cljs.hl
file.
the ns
would have the same semantics, and be more tooling-friendly perhaps because it is consistent. additionally, it would maintain the contract that .cljs
files start with ns
.
tools should be able to assume that the ns
form is the real one and not something else that is appropriating the name
i, personally, care less about this particular aspect. but this would be an .hl
ns
, not a .cljs
ns
.
which would then create a legal cljs file with a real ns for the clojurescript task.
that's why i think it should be a .hl file instead. and since it would be a .hl file, then it could use a hoplon ns
.
the current ns+ implementation in hoplon tinkers with a file type/contract it does not own.
and typically our file extensions specify which compiler they belong to, eg .java
-> javac, .cljs
-> clojurescript, in this case .hl
-> hoplon. i think it is analogous to invading someone else's namespace.
if we do want to extend .cljs
files more generally, with something like ns+
, we should do it in the cljs
task i'd imagine (at least within the boot world, these files would still be illegal in the larger cljs ecosystem).
i think the same principle applies to tooling; editors should be able expect an actual ns at the top of any .cljs
files. i only meant to convey there might be an incidental benefit of convenience when users associated .hl
files with clojurescript in their editors, since the only syntactic delta would be the addition of the :page
form to the macro. an ide might not recognize ns+
.
it works great now. whether or not you want to propagate it to the clojurescript task, and effectively introduce boot extensions to clojurescript, is another question.
lol. yeah... i heard, somewhere, that :require-macros
is no longer needed by cljs; i've not verified this, but that might negate any benefit of doing this anyway if true.
yeah. you should submit a patch for bound-fn too, if they can introduce your binding
it in a backwards compatible way.
ah, yeah. i never use the :all
because i don't like dumping a bag-o-symbols into my ns implicitly.
convenient. easy at first maybe. less simple. we tried that with hoplon in page
s implicit :refer :all. 😕 i find in practice i either refer in a small handful of symbols (even in test), or simply namespace them with :as
.
there's a scenario out there, i'm sure, where i might be pragmatic enough to use :refer :all
- but i've yet to encounter it.
anyway, my only point is that :refer :all
is an edge case so i personally don't care much about it, and i wonder if it does more harm than good. maybe the fact is is missing from cljs is a feature and not a bug because it encourages better practices.
That's the pattern we are following but the inconvenience is that you have to remember what are the frequently used, hence referred, symbols and which ones need namespacing. On top of that you need to maintain a team wide consensus on the ns aliases too...
I see custom ns macros as a harm, because they break cursive, which is the best tooling really these days (for those who have super strong machines with a lot of ram.)
the idea that some rando off the street should be able to jump into your codebase and start typing immediately is silly
i could see a scenario where i'd use with with the core hoplon/ui
ns, in the same way though.
yeah, but when you refer in 100 things, then you get surprises because you just introduced 100 more keywords that will collide with other things, imho.
so you create a header
function, then you get errors. because you :refer :all
'd all the html things.
you see a warning that you're overriding something and which namespace the thing was originally defined in
because i assume that if it isn't explicitly defined, that it is a core language fn.
who knows, i might start using it in .hl
files with ui core at some point. but interestingly, is there an :exclude :all
?
say i wanted to eliminate all the clojure core fns by default in a view (notwithstanding the necessary ns
macro). could be useful, maybe, if i were building views where pretty much everything was a ui elem.
i was wondering if :refer-clojure
supported :exclude :all
, but i guess the :only
construct would work too for the same purpose if that works the way it seems it would.
i really like the semantics of ns+, and i don't use cursive either. i was suggesting that it should be owned by the hoplon compiler and therefore be ns
for hoplon .hl
files, not .cljs
files.
hl files -> hoplon compiler, cljs files -> clojurescript compiler. one compiler/task should not be modifying another compilation task's files.
the files should be legal regardless of the time and their position in the build pipeline.
@flyboarder the thing that got me looking at nil child values was this line of hoplon/ui: https://github.com/hoplon/ui/blob/master/src/hoplon/ui.cljs#L609 if you don't give the page a title, none of that form is nil and none of the stuff after it happens.
i guess a page would pretty much always have a title, but it bit me during quick test apps
i think what we want to do is make a (remove nil? args)
in the let binding before the cond
and in the places where we do flatten
on seq or vector args we need to put a (remove nil? (flatten x))
too
@micha i had to duplicate this part twice in the patch i implemented for mk! that might be a sign there is another problem here
it's hard to factor around the parse-args function
yeah, i observed significant slowdowns in ui when i introduced a seq into the elem constructor.
like really i think hoplon should just be the linkage between javelin cells and dom elements
but the attribute providers and so on are really just to help you get started with some reasonably sane defaults
well i think it's important that a user can get a basic thing working without other libraries
I think there needs to be better separation from the custom elements and primitive elements
in core
not sure what you mean by that
oh yeah not that they should be a separate library but from core
the same way we do attributes
you could include hoplon/ui
or include hoplon/html
, or whatever... and hoplon/hoplon
comes as a part of those as a dependency.
one version of hoplon.jquery isn't guaranteed to work with a different version of hoplon.core
i'm less opinionated about this issue though, nor am i convinced my suggestion is the right way to do it.
hoplon.jquery is just one implementation of custom attributes that is sufficient to get started and make some apps
@flyboarder one thing though, i think we should namespace the goog attributes
maybe both?
otherwise its not backwards compatible
could a menu of different attribute options be unnecessary though, maybe in the same sense that INode
could introduce options that are undesirable?
why would we want the confusion of supporting jquery attributes and goog attributes?
@flyboarder compatibility is the reason
i get the idea of supporting one thing, i dunno about a menu of attribute providers.
libraries that are written against the jquery :click
for example, won't work if jquery .goog is loaded
@jumblerg we can implement both without causing issues, they are all already namespaced
the standard click is browser behaviour
the attribute providers extend that however they want
if you want to write your own compatibility layer you'd make your own attribute provider
agreed we should allow other people to hook in with goog, or whatever they want to make. i simply don't think we should have goog attribute providers in hoplon/hoplon.
we'll have some people building apps with jquery, others with goog, and to what benefit?
i think that, as we use hoplon over time, we try lots of things, but eventually uncover best practices and idioms; these abstractions tend to get encoded into hoplon incrementally where others can use and benefit from them. we eventually settle on these best practices, and i think we should only offer the abstractions that we use ourselves, that work best for us, as part of core hoplon so we can avoid forking the community (while still giving others the opportunities/hooks to innovate themselves and perhaps find new approaches we can include).
it is better to work through different approaches here as a group, and settle on a single supported approach based on our collective experience and knowledge, rather than giving people a menu of options.
take goog attributes, for example. i haven't tried them. if some of us are using them, and there's a substantial benefit to them, then we should work through that here, and maybe we encourage the use of those moving forward while attaching deprecation notices to jQuery attributes for backwards compatibility.
let's agree on a single approach as a group where we're well equipped to sort through these options rather than devolving the choices to individuals, esp newcomers.
@micha one issue tho is that the compatibility layer is limited to being able to convert regular elements to a compatibility type, this breaks down when elements can only be constructed
for example with jquery I can always convert an element to a jquery element, but there are cases when I cannot do this, I instead must construct the element directly
like I can go (js/jQuery #some-elem)
and that gives me a jquery object, but with many js libraries I must use the libraries constructor for the element
like for an IDE which modifies the DOM
most ide libs need to be constructed
and cannot convert an existing node with each desired method call
right when you first construct the element, but currently thats handled by hoplon
right like for a web ide
residing in DOM
when elements need to be constructed with their own constructor
nothing specifically but then I cannot construct them the same way as I do regular hl components
I can't mix an external libs constructor and hoplon attributes
but what about when the parent is required to already exist?
I think the main issue is that the jquery pattern dosent always work with other libs
like when using ace editor