This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-12
Channels
- # aleph (10)
- # beginners (79)
- # boot (81)
- # chestnut (3)
- # cider (9)
- # cljs-dev (336)
- # cljsrn (17)
- # clojure (121)
- # clojure-boston (1)
- # clojure-italy (4)
- # clojure-nl (1)
- # clojure-russia (218)
- # clojure-spec (32)
- # clojure-uk (98)
- # clojurescript (109)
- # cloverage (1)
- # core-async (5)
- # cursive (17)
- # datascript (15)
- # datomic (38)
- # editors (4)
- # emacs (6)
- # graphql (1)
- # hoplon (140)
- # instaparse (1)
- # jobs (2)
- # klipse (1)
- # leiningen (4)
- # lumo (2)
- # mount (103)
- # off-topic (3)
- # om (8)
- # onyx (19)
- # parinfer (32)
- # pedestal (3)
- # precept (32)
- # re-frame (33)
- # reagent (24)
- # remote-jobs (11)
- # rum (1)
- # spacemacs (1)
- # specter (37)
- # unrepl (4)
- # untangled (43)
- # vim (11)
@flyboarder the (cell= (and data value))
was something i tried too. yes, it evaluates any time either data
or value
changes but it only ever returns value
, the do!
will only trigger on the return value, not simply cell execution
that's just because and
only returns the last truthy value, but even if it returned the whole thing, we don't want data
to get serialized into our input value...
@thedavidmeister yeah I see your point
@flyboarder i'll try to write a nicer version of my proposed fix
i haven't used alts!
before, but i think this is what it's for
(and (sequential? value)
(every? cell? value))
(let [vs (apply javelin.core/alts! value)]
(do-watch vs #(do! elem this (first %2))))
seems very close to what i want
but for some reason the initial value of vs
created by alts!
drops the first value in the sequence so that (first %2)
sees data
rather than value
i'll play around with it more later 🙂
conceptually it's very close to the (cell= (and data value))
approach
I’d rather there was something explicit to serve this issue, e.g. (input :value (hoplon/two-way :cell value-cell :depends [data]))
then you can add either your own do! multimethod on top which will implicitly create that from [value-cell data]
or abstract any other way you like
@dm3 but it's not 2-way, that's the point
it's avoiding 2-way
i thought alts! more or less did what you're suggesting, right?
creates a cell that evaluates when any of a list of other cells changes
what, if i know hoplon or don't know hoplon?
because if i don't know hoplon i have no idea what the value is
sure... initially
so i'd be wrong
because cells have a time model
x and y both are though
(and (sequential? value)
(every? cell? value))
ok maybe
i see what you're saying
but the current behaviour is implicit based on whether something is a value, function or cell
what do you think (input :focus x)
does?
but if x
is a function, it doesn't even trigger do!
it triggers on!
so, when i was first learning hoplon, this was 100% something i had to learn
but now that i know hoplon it makes perfect sense
i don't think having 3 implicit options and 1 explicit option is a good idea
it should be internally consistent either way
hell, i'd probably support a proposal that if you pass a list of functions, to bind them all as event handlers 😛
or maybe there's an explicit api and an implicit one and you use whatever is comfortable
e.g. :on/click
vs. :click
and passing anything other than a function to the former is an error
i don't necessarily disagree with your criticism of how it works
but this bug is actually really bad for what i'm trying to build
and i don't want to deal with the implicit/explicit can of worms if i can avoid it
it's neither
it's the first value of alts!
no it isn't
because a falsey value in the first slot will still trigger
it's alts!
😛
;; Creates a formula cell whose value is a list of changed values in the cells cs.
imo that seems like the most natural fit for interpreting a list of cells anyway
because and
and or
already exist and work better inside a cell than outside
the only "trick" that i'm using is extracting the first item in the list as "the value"
that bit i'll admit is a bit of hand waving
well that is 2-way data, right?
and, no, to answer your q
i assume it would work though
worst case scenario you get an infinite loop where "changing" the value to the same thing triggers another "mutation"
potential scenario is that there are weird bugs where you type stuff and the keys you press flicker in/out of existence as data propagates around javelin and back into the DOM
best case scenario is that you're reading from the DOM, so it's 2-way i think
well...
i'd like to see more support in hoplon for the various *Observer APIs that are maturing in general
but i don't know if it's a solution for my current problem, or even if it is, whether it's a good idea in this case
seems like we have to pick the least bad option out of:
- have a known bug that is pretty bad in some situations
- add to the implicit api for do!/on!
- have an implicit/explicit split in that api
- do something with 2-way data
I’d have to play around with this issue to actually completely understand why we get the result that we get
otherwise I’d use a separate attribute with a special do! which understands a seq of cells
the issue is that i cannot sort inputs on their value
so, for example, if i have a form with a table layout and i want to click sort, i can't do that 😞
why should i need a custom attribute for such a basic need?
i mean, sorting elements is hardly advanced UI-fu
but I somehow feel that the problem/solution space isn’t explored sufficiently. I may be wrong!
oh sure
so... the short version
after days of investigation
is that the thing that makes do!
work at all is a do-watch
on whatever cell gets associated with :value
so if that cell doesn't change its value, which is possible during sorting operations when you have multiple elements with the same value, then the do!
is not triggered
so it looks like values are "copied" after the sort rather than "moved"
e.g. 1 1 2 should becomes 1 2 3 if you change the first 1 to a 3
but it looks like 3 2 3 in the UI because the first input retains the value 3 and hoplon changes the last input to 3
when hoplon sets the last number to 3 it must also set the first number to 1 to "move" it
so a mutation observer can probably detect that you typed the number 3, but so does the :input
event, so what next?
what we can do though, is trigger do!
when either the value cell changes for a single element or on all the elements whenever the overall sort order changes
yeah basically, so the sorting "redos" all the elements
uh not quite
something in between
yes it is
which is probably why the bug has survived so long
it's basically because when you have elements in a for-tpl it doesn't actually re-order elements in the DOM
it just binds values to DOM attributes
which simulates a sort
but the simulation is not perfect 😕
i actually wrote a test for the issue, so if you want to mess around with mutation observers i can plug it into the test and see how it goes 🙂
mmm, i know that feeling
actually my fix doesn't totally work anyway because alts!
doesn't quite do what i expected
so i've still got work to do on this
oh, alts!
is not what i want at all!
or at least, not the way i'm using it
(and (sequential? value)
(every? cell? value))
(let [vs (apply javelin.core/alts! value)]
(do-watch vs #(do! elem this @(first value))))
this works
@micha @alandipert either of you have thoughts on ^^?
also, what is the process for reviewing/merging PRs? https://github.com/hoplon/hoplon/pull/189/files should be a lot less controversial
@thedavidmeister #189 doesn't seem controversial, I can merge that, it's safe enough 😝
@flyboarder @thedavidmeister yes looks good to me too - merge at will
Just going to put this here....