This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-12-13
Channels
- # bangalore-clj (5)
- # beginners (94)
- # boot (145)
- # cljs-dev (4)
- # cljsjs (79)
- # cljsrn (18)
- # clojure (343)
- # clojure-dev (21)
- # clojure-dusseldorf (6)
- # clojure-india (1)
- # clojure-italy (2)
- # clojure-nl (4)
- # clojure-russia (62)
- # clojure-sanfrancisco (1)
- # clojure-spec (109)
- # clojure-taiwan (1)
- # clojure-uk (103)
- # clojurescript (102)
- # code-reviews (30)
- # component (1)
- # cursive (39)
- # datascript (7)
- # datomic (68)
- # emacs (11)
- # figwheel (1)
- # gorilla (1)
- # hoplon (234)
- # off-topic (46)
- # om (52)
- # onyx (32)
- # planck (9)
- # proton (4)
- # protorepl (5)
- # random (1)
- # re-frame (36)
- # ring (18)
- # ring-swagger (1)
- # specter (6)
- # untangled (3)
- # vim (56)
Having a problem with hoplon. I want to present things different ways. Some times I want to show the parts separately, other times all at the same time. So I broke my code into several functions, call them in two different places, and use toggle to control which view show be present.
One of the parts has all the controls--buttons and state display. When I have it display by itself, it is fine. But when displaying it in a table with the other parts, it comes up blank.
Here's the code, with all this stuff at the end of the file: https://github.com/rolonicArk/simpleArk/blob/master/src/console/client.cljs
when you say “blank"
is it actually in the DOM
like, with inspect element
ok, I found element in the console. Thanks @thedavidmeister !
ok cool
so it’s an issue with updating the dom, not the toggle
i’ve seen in my code that you can’t reuse elements
(let [e (div)] [(div e e)])
will be <div><div></div></div>
for example
that might be it?
div returns an actual DOM element
(let [e (div)] [(div e e)])
won’t work but (let [e div] [(div (e) (e))])
will
it literally returns a dom element
div
is a function that returns a new dom element
it isn’t higher order
if you call it twice, yes
could you link the line number of the code that’s not working?
that file you linked is pretty long
do-commands is not a function
but it’s just a dom element
https://github.com/rolonicArk/simpleArk/blob/master/src/console/client.cljs#L364
(def do-commands (h/div …))
maybe you meant (def do-commands #(h/div …))
sure, you have a bunch of detached dom elements that you are composing
You nailed it @thedavidmeister!
which is actually awesome for testing, as you can probe your detached elements however you want without needing a whole page
but yeah, if you want more than one you have to promote what you’re doing to a function 🙂
I am still new enough at hoplon that the code-walking makes me bug prone, as sometimes I need to dereference a cell (when outside of code walking) and sometimes not.
if you want to make formulas more explicitly, you can also use the formula
function
i.e. (cell= (+ x y))
= ((formula +) x y)
(formula is a function)
dude yes
I also do not like magical things in general. So, for example, I've been converting my .cljs.hl files to .cljs files and using :as. I think it lowers one of the barriers to acceptance. Too much hoplon magic means only hoplon devs will be happy with my code, at best.
oh derp, you're using formula in your macro there
so now that i've actually read the code and your comment introducing it, i think it's great
my only suggestion would be to perhaps call it with-formulas
i do enjoy that name hehe
I have no real objection to with-formulas
, though, other than vague uneasiness that it co-opts the with
metaphor.
yeah, which is kind of not perfect, since the names here are lexical
vs. dynamic as in with-open
i guess it's not the name that's dynamic, but the resource. ie if you capture the file in a closure and return it, the file will have been closed
the real reason i prefer with-
is because editors indent 'defun-style' by default usually
which is petty, and i'm lazy
me neither
i think it's cool tho
And you can bind more than one cell, as in the docstring example. Arbitrary destructuring, since it just turns into let.
In the map, the keys are the binding forms, and the values are the cells against which to bind.
This is similar to generalized map destructuring in a let (which no one ever uses :))
OK, so Hoplon question. In lots of places, I’m conditionally building up UI, and I would like nil
to mean nothing
. Instead, it seems to stop rendering. E.g.:
yeah - that's a bug
(def NIL ())
😎
actually if you have a minute to make a ticket, that would be helpful
this has come up before but we keep forgetting 🙁
oh wait - think there might already be a PR, https://github.com/hoplon/hoplon/pull/160
yeah - that's the one
i think micha was gonna do a javelin release today (2x perf!), i'll try to do a hoplon one also
I think we may want to attempt something else there tho, like a flatten 😹
Or remove nil?
@candera the way i handle the case where i want to swap!
on a cell inside a formula is like this:
is that different from a vector that is constrained to have an even number of forms in it?
No, not really. But I wanted vector to have another meaning, so it would be ambiguous.
I definitely like having two names for two things, and would not object to two forms since the semantics are different. In this case I think the harm is small, but generally the impetus towards not overloading things is one I like.
We can stop acting like they’re a limited resource. Good names are hard, but I think we need to stop overloading as much as we do. Talking about myself mostly here - not Hoplon in particular.
Seriously Slack? I thought I left this sort of nonsense behind when I stopped using HipChat.
My weather app has a fair amount going on - I should be able to tell you if there’s an improvement pretty easily, as I already have some metrics in place and can add more.
Not quite as many as you’d think - I can't use cells for the individual squares, because slow. But still a fair number.
@alandipert I think that PR I submitted for the nil hoplon element args was kinda a naive fix and I hadn't really considered or properly understood the performance implications, which i remember @micha had some comments on. I will play around with it now a bit though and test things out with the hoplon master. and get a better sense for how much extra work is happening as a result of that change
Different problem now. I call do-commands to generate the same dom elements in two differrent places and use toggle to select the one that should be visible. But initally both are visible. Any ideas? Here's the code:
@laforge49 I think your :style is overwriting your :css on your second div.
@micha: I noticed a thing about defelem, it will accept multiple body forms but only display the first one
So if you accidentally close the elem form it's hard to debug
That might be what it's doing
I just remember there is nothing to help find the problem
Ran into this yesterday
Right, hmm I guess there isn't an easy way to check for this since we can't know what the developer intended
A hoplon newbie here. How can I use an input cell whose value is a reference to an another input cell, inside a formula cell..?
Kinda need that for a meta-ish app.. for example, (i do not have the exact snippet handy) a vector of maps like [{:name "a" :ref (cell 1234)}] and an element (defelem) iterating over these to display names and values.
my formula cell has something like (cell= (str (:name element) "," (deref (:ref element))))
the problem that I have is , If i mutate the reference (reset!), the view doesn't get updated
but if the mutation touches both name and ref part of the element , then the view refreshes (as the formula cell uses both name and ref keys)
think of an app where the data flows into the app (somehow) and the user interface is just an exploratory (drag dropish system) surface where he can define cells, formulae, etc...
the app as such doesn't come with pre defined cells whereas the user defines his views over the data (by defining cells and formula cells)..??
since there is no eval in the client via clojurescript you will need to create cells via your own little interpreter
but anyway, your comment answered it all (updating the value inside a cell does not change the identity of the cell)
yeah I understand that... its just a hobby project (which i'm sure, i will never complete)
that's always nice to hear. what were you using before?
anything seem lacking compared to reframe?
not much.. It was a pleasure using re-frame... sometimes interop with third party js plugins was offputting. ever since the latest release (dynamic subscriptions and effects handlers), it was a breeze.
@jumblerg How do you do :toggle
functionality on UI elems? With the :v
attribute for visibilty, hidden elems still take up space in the layout flow.