This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-02-02
Channels
- # admin-announcements (33)
- # announcements (2)
- # beginners (75)
- # boot (340)
- # braid-chat (6)
- # cider (30)
- # cljsrn (44)
- # clojars (19)
- # clojure (169)
- # clojure-austin (12)
- # clojure-czech (1)
- # clojure-japan (6)
- # clojure-miami (1)
- # clojure-poland (7)
- # clojure-russia (83)
- # clojurebridge (4)
- # clojurescript (166)
- # community-development (55)
- # component (2)
- # core-async (39)
- # core-matrix (3)
- # cursive (32)
- # data-science (3)
- # datavis (3)
- # datomic (58)
- # dirac (28)
- # emacs (4)
- # events (7)
- # hoplon (254)
- # immutant (29)
- # jobs (2)
- # jobs-discuss (4)
- # ldnclj (35)
- # lein-figwheel (3)
- # mount (202)
- # off-topic (9)
- # om (123)
- # onyx (22)
- # parinfer (112)
- # proton (11)
- # re-frame (6)
- # reagent (43)
- # ring (3)
- # spacemacs (2)
I'm slowly converting to the Hoplon way of doing things, but it's not easy . For example, I have the following pattern repeated a few times (the app is kind of like a spreadsheet with cells that you can move around):
(defn move-cell [cells idx new-pos]
(update cells idx #(if (can-move? cells % new-pos) (move % new-pos) %)))
(defelem sheet [{:keys [cells]} _]
(loop-tpl [[idx c] (cell= (map-indexed vector cells))]
(sheet-cell :on-moved #(swap! cells idx move-cell %))))
it seems like I could make the above more direct, somehow leverage the cells/formulas and avoid passing the callbacks, but I'm not sure how. E.g. I cannot update the cell bound to c
directly as it's a formula, so I go through the index. Am I making some fundamental mistake here?so the things that use the lens don't need to know about how to update the underlying stuff
Here's the lens demo: https://github.com/hoplon/demos/tree/master/lens
and you want to make it so that you can do (reset! the-a-key 42)
and it will update the formula
(defc the-map {:a 1 :b 2})
(defc= the-a-key
(:a the-map)
(fn [new-value] (swap! the-map assoc :a new-value)))
when you call swap!
or reset!
on a lens the new value that you're trying to set is passed to that callback
the callback then updates the underlying thing, so the thing that uses the lens doesn't need to know how to do that
It displays a map, a key and a value. You can change the key and the value and see the immediate change in the map.
(defn path-cell [c path]
(cell= (get-in c path) (partial swap! c assoc-in path)))
(defc a {:a [1 2 3], :b [4 5 6]})
(def c (path-cell a [:a]))
Another handles maps, doing the get and assoc. You combine these two lenses and drop them into a formula cell.
no purpose when things are simple. But too often the structures are deep. Dewdrop lenses are composable but also it is easy to create custom lenses. So dealing with deep and complex structures becomes a reasonable thing.
i'm skeptical because it redefines swap!
and reset!
to be pretty much the same as the core ones, but incompatible
whenever i find myself reimplementing core functions i always later see that it was unnecessary
I kept things simple by allowing you to define new lenses from a map with 2 values. In java I would have used subclassing.
1. the lens object is tightly coupled to the data, but the data doesn't provide the lens itself, so you need to know at the call site which lens to use with which data
so the next thing you will do is create a whole new set of lswap!
functions that do swap and reset and whatnot for some specific lens
(def swap1! (partial lswap! foo))
(def swap2! (partial lswap! bar))
(swap1! data1)
(swap2! data2)
compare that to a thing that uses lswap!, you need a different function for each type of lens
yes yes and when you use a dewdrop lens in a formula cell, the swap! still works on the formula cell. I don't see your point at all.
anyone else using on windows 10 successfully? apparently BOOT_EMIT_TARGET=no isn't good enough anymore - https://github.com/hoplon/hoplon/issues/80
Dewdrop lets you define complex transformations for use in both the client and server sides and also works with hoplon/javelin.
@alandipert: which version of windows btw?
I'm using unshared worker, i.e. worker gets its own .js file. And worker.js MUST NOT reference window, which it does.
The problem with this demo is that once it starts, it kills the workers. --It is not an interactive demo. So you would think everything would run fine.
java.io.IOException: Couldn't delete C:\Users\Bill\.boot\cache\tmp\Users\Bill\Documents\aatree\aademos\servant-demo\dys\mm3x96\main.js http://clojure.java.io/delete-file/invokeStatic io.clj: 434 http://clojure.java.io/delete-file io.clj: 430 ... boot.file/delete-file file.clj: 54 boot.tmpdir.TmpFileSet/commit! tmpdir.clj: 246 boot.core/commit! core.clj: 434 boot.task.built-in/fn/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn built_in.clj: 274 boot.core/run-tasks core.clj: 862 boot.core/boot/fn core.clj: 872 clojure.core/binding-conveyor-fn/fn core.clj: 1938 ... Writing main.cljs.edn... Compiling ClojureScript... ò main.js java.nio.file.FileSystemException: C:\Users\Bill\.boot\cache\tmp\Users\Bill\Documents\aatree\aademos\servant-demo\dys\mm3x96\main.js: The process cannot access the file because it is being used by another process. file: "C:\\Users\\Bill\\.boot\\cache\\tmp\\Users\\Bill\\Documents\\aatree\\aademos\\servant-demo\\dys\\mm3x96\\main.js" reason: "The process cannot access the file because it is being used by another process.\r\n" sun.nio.fs.WindowsException.translateToIOException sun.nio.fs.WindowsException.rethrowAsIOException sun.nio.fs.WindowsException.rethrowAsIOException sun.nio.fs.WindowsFileSystemProvider.implDelete sun.nio.fs.AbstractFileSystemProvider.deleteIfExists ... boot.file/hard-link file.clj: 145 boot.tmpdir.TmpFileSet/fn tmpdir.clj: 261 boot.tmpdir.TmpFileSet/commit! tmpdir.clj: 247 boot.core/commit! core.clj: 434 adzerk.boot-cljs/eval328/fn/fn/fn boot_cljs.clj: 230 adzerk.boot-cljs/eval277/fn/fn/fn boot_cljs.clj: 135 adzerk.boot-cljs-repl/eval429/fn/fn/fn boot_cljs_repl.clj: 171 boot.task.built-in/fn/fn/fn/fn built_in.clj: 325 boot.task.built-in/fn/fn/fn/fn built_in.clj: 323 adzerk.boot-reload/eval516/fn/fn/fn/fn boot_reload.clj: 125 adzerk.boot-reload/eval516/fn/fn/fn boot_reload.clj: 124 boot.task.built-in/fn/fn/fn/fn built_in.clj: 166 boot.task.built-in/fn/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn built_in.clj: 274 boot.core/run-tasks core.clj: 862 boot.core/boot/fn core.clj: 872 clojure.core/binding-conveyor-fn/fn core.clj: 1938 ...
' java.io.IOException: Couldn't delete C:\Users\Bill\.boot\cache\tmp\Users\Bill\Documents\aatree\aademos\servant-demo\dys\mm3x96\main.js http://clojure.java.io/delete-file/invokeStatic io.clj: 434 http://clojure.java.io/delete-file io.clj: 430 ... boot.file/delete-file file.clj: 54 boot.tmpdir.TmpFileSet/commit! tmpdir.clj: 246 boot.core/commit! core.clj: 434 boot.task.built-in/fn/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn built_in.clj: 274 boot.core/run-tasks core.clj: 862 boot.core/boot/fn core.clj: 872 clojure.core/binding-conveyor-fn/fn core.clj: 1938 ... Writing main.cljs.edn... Compiling ClojureScript... ò main.js java.nio.file.FileSystemException: C:\Users\Bill\.boot\cache\tmp\Users\Bill\Documents\aatree\aademos\servant-demo\dys\mm3x96\main.js: The process cannot access the file because it is being used by another process. file: "C:\\Users\\Bill\\.boot\\cache\\tmp\\Users\\Bill\\Documents\\aatree\\aademos\\servant-demo\\dys\\mm3x96\\main.js" reason: "The process cannot access the file because it is being used by another process.\r\n" sun.nio.fs.WindowsException.translateToIOException sun.nio.fs.WindowsException.rethrowAsIOException sun.nio.fs.WindowsException.rethrowAsIOException sun.nio.fs.WindowsFileSystemProvider.implDelete sun.nio.fs.AbstractFileSystemProvider.deleteIfExists ... boot.file/hard-link file.clj: 145 boot.tmpdir.TmpFileSet/fn tmpdir.clj: 261 boot.tmpdir.TmpFileSet/commit! tmpdir.clj: 247 boot.core/commit! core.clj: 434 adzerk.boot-cljs/eval328/fn/fn/fn boot_cljs.clj: 230 adzerk.boot-cljs/eval277/fn/fn/fn boot_cljs.clj: 135 adzerk.boot-cljs-repl/eval429/fn/fn/fn boot_cljs_repl.clj: 171 boot.task.built-in/fn/fn/fn/fn built_in.clj: 325 boot.task.built-in/fn/fn/fn/fn built_in.clj: 323 adzerk.boot-reload/eval516/fn/fn/fn/fn boot_reload.clj: 125 adzerk.boot-reload/eval516/fn/fn/fn boot_reload.clj: 124 boot.task.built-in/fn/fn/fn/fn built_in.clj: 166 boot.task.built-in/fn/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn/fn built_in.clj: 277 boot.task.built-in/fn/fn/fn/fn built_in.clj: 274 boot.core/run-tasks core.clj: 862 boot.core/boot/fn core.clj: 872 clojure.core/binding-conveyor-fn/fn core.clj: 1938 ... '
Now, about that problem with shared web workers. It was fixed: https://github.com/adzerk-oss/boot-reload/issues/57
which is why I need to retest with 2.5.5--it should still fail but I can't in all fairness report the error with 2.6.0-SNAPSHOT!
The fix was released 3 days ago and my test is failing with it. Just failing at a later point methinks.
if I create formula cells in the loop-tpl body, how do I make sure they're destroyed when number of elements decreases?
@micha AFAIK the cells aren't GC'ed, so need to destroy them explicitly. Should I attach some sort of onremove
to the elements?
in my case it's
(loop-tpl [[idx c] (map-indexed vector cells)]
(let [max-size (cell= (max-size cells c))]
(sheet-cell ...)))