This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-04-10
Channels
- # admin-announcements (1)
- # boot (464)
- # braid-chat (4)
- # cider (6)
- # cljs-dev (7)
- # cljsrn (1)
- # clojars (1)
- # clojure (26)
- # clojure-france (1)
- # clojure-japan (6)
- # clojure-russia (35)
- # clojure-uk (3)
- # clojurescript (25)
- # cursive (5)
- # hoplon (389)
- # om (20)
- # om-next (1)
- # onyx (5)
- # other-lisps (1)
- # overtone (9)
- # planck (12)
- # proton (7)
- # re-frame (10)
- # reagent (13)
- # ring (23)
- # spacemacs (11)
hoplon cleanly separates the dom, which is by definition mutable, from the application state, which is data (and immutable, stored in reference types -- javelin cells)
so in this environment it would be natural to have elements in the tree manage their own state as much as possible
so if you type in one paragraph, the other paragraphs don't need to know about it, or be rerendered or anything
(page "index.html")
(def count (cell 0))
(def color (cell= (if (= 0 (mod count 5)) "red" "blue")))
(with-interval 1000 #(swap! count inc))
(html
(body
(p :css (cell= {:color color})
(span (text "count = ~{count}")))))
if you run that and observe the DOM in chrome dev tools you will see that only the parts of the dom that need to change will change
when the list shrinks it removes the elements from the end and puts themn back in the pool
(page "index.html")
(defc items ["one" "two" "three"])
(with-timeout 1000
(swap! items conj "four")
(with-timeout 1000
(swap! items #(vec (rest %))))
(html
(body
(ul
(loop-tpl :bindings [item items]
(li :text item)))))
I was thinking about the javelin always-consistent-cell-graph and e.g. re-frame event->handler->state-update->react-rerender models
since formula cells are constructed from functions you can make hand optimized javascript for them too
we have a pretty huge application now, similar to the aws console in terms of the problem it's solving
the only thing we need to do is carefully manage how we fetch state from the backend api
but one thing it does is it supports an infinite number of anything in the UI, without degrading performance
so we needed to develop a strategy for dealing with that, because the data even for a single user won't fit in memory in the browser
on the other hand, I have a spreadsheet-like application which allows constructing financial scenarios, using datascript to manage the pretty complicated UI model and events over websocket to allow realtime collaboration over the spreadsheet (ala google docs)
@l1sp3r: btw, another big benefit of Hoplon is Micha who'll write an essay to answer a question pretty much any time
there is the addEventListener thing too, seems to be supported in all evergreen browsers
@micha: did you ever run into needs/wants to reproduce clientside errors or reproduce the complete state of the client? I know the guy behind re-frame touts that as a great benefit of the single state map. Remember CircleCI people blogged about this feature helping them reproduce bugs, etc... What do you think?
the tradeoff there is that your components get a lot more complex when you have the one atom
Following works in plain JS: http://codepen.io/badyl/pen/yOvOPM
but not in hoplon: https://github.com/pbzdyl/hoplon-semanticui-issue
With hoplon, when I click in the dropdown field I am getting an error in JS console:
semantic.inc.js:18207 Transition: Element is no longer attached to DOM. Unable to animate. slide down in <div class="menu" tabindex="-1">…</div>module.error @ semantic.inc.js:18207module.animate @ semantic.inc.js:17527module.initialize @ semantic.inc.js:17425(anonymous function) @ semantic.inc.js:18322jQuery.extend.each @ jquery.inc.js:648jQuery.fn.jQuery.each @ jquery.inc.js:270$.fn.transition @ semantic.inc.js:17373module.animate.show @ semantic.inc.js:7050module.show @ semantic.inc.js:4536module.event.search.focus @ semantic.inc.js:4966jQuery.event.dispatch @ jquery.inc.js:3074elemData.handle @ jquery.inc.js:2750jQuery.event.trigger @ jquery.inc.js:2986jQuery.event.simulate @ jquery.inc.js:3301handler @ jquery.inc.js:3552
reload.cljs:63 Reload
but I suspect that hoplon might be removing and adding again some elements when it detects that semantic ui is changing the DOM
@piotrek: I think you had the same exact issue last time, no? When you added a span
somewhere in the autocomplete and the issue went away?
yeah, but then I was using a static list of options and a workaround was to create a dummy element inside a div
I will try to get dropdown with div
instead of select
working but I would like to fix the problem anyway and don’t use workarounds
I'm afraid you'll have to debug which element that is that gets detached (or never attached in the first place)
try with latest master as an interaction with jQuery.remove
was fixed there that caused issues
also I'd add the element to a div inside body
as I think body
gets some special treatment in Hoplon and might have more bugs. I might be completely wrong though.
@micha - I was wondering if you have thought about/worked with Elm (or another library using Applicative FRP instead of Monadic FRP implemented in Javelin). It seems like it also allows for clean abstraction of functionality in modules. The biggest theoretical difference is that with Applicative FRP you're forced to declare all your inputs beforehand, while in Flapjax/Javelin they can be created on the fly. However, in real Hoplon applications the graph is pretty static too (if you consider things like loop-tpl
just reusing a "template" of a subgraph)
hey this might be off topic as it’s probably more of a cljs question, but since it’s a hoplon app i’m working in i’m just going to ask it here: is it possible to use multimethods where the defmulti is defined in one namespace and defmethods can be defined in one or more other namespaces?
@raywillig: sure
@raywillig: sure, you just need to require the namespaces
so in the third namespace where I want to use the defmethods, i have to require both the namespace with the defmulti and the one(s) with the defmethods I want to use?
suppose there are defmethod calls that edfine dispatches for that multimethod in some other namespace
and now suppose you have a 3rd namespace my.ns where you want to use the do! multimethod
in my.ns you need to require hoplon.core for sure, so you can use the hoplon.core/do! name
if something else already required it then you're ok and you don't strictly need to require it again
it seems like the way Javelin expresses signals is best suited for a kinda-mutable environment of Clojurescript
well, I think it can work if you develop in your safe little world and sanitize anything that goes outside
I've opened the thesis again and can see that he mentions Flapjax favourably on the accounts that are signifcant when comparing Elm to other FRP frameworks: 1. elimination of space leaks through not being lazy 2. light conceptual load through not mentioning the monadic machinery
oh man, how I can see some people having a red face and gasping for air after you've said that
To be honest it's pretty elegant, was put off by the complexity of go using an element
regarding types: https://dl.dropboxusercontent.com/u/7810909/talks/parametricity/4985cb8e6d8d9a24e32d98204526c8e3b9319e33/parametricity.pdf I kind of agree with the material, but on the other hand I have the experience and joy of working with Clojure and the painful experiences of designing abstractions in Scala. I guess I'm just not smart/interested/motivated enough...
when i see haskell programmers making finance applications without unit or integration tests then i'll be convinced
It was interesting, was more about the previous Dev experience of the team than the language
and it's more powerful in a typed language like Haskell, actually. If you have a properly typed abstraction, and you come up with good properties - you have a very good chance of the implementation being correct
i still think that if this were the case you would see a big difference between the number of tests in real demanding applications between haskell and clojure
Maybe the issue isn't that type systems aren't helpful, maybe it's that they're not good enough yet
the fundamental flaw that i see is that the compiler is essentially trying to run the program without running the program
with dependent types the difference between the compiler and the program is even less apparent
for me expressive power beats type systems by a large margin, because more powerful abstractions can give the human the power to see if it's correct or not
if you can't tell if your program is correct, in lisp you have so much power to refactor so it's clear
the only thing the hoplon compiler does is generate the html boilerplate and to refer the hoplon core vars into your namespaces so you don't have to namespace qualify them
because of the way the cljs compiler works you can't do :refer :all
in a cljs namespace
But from spending 15 years working in financial services know there's a desperate need for a product like this
the spreadsheet seems to be the ultimate form. I think folks at OpenGamma have realised that, for example
I have to get some sleep, but if you want to discuss further drop me a line at: <mailto:[email protected]|[email protected]>