This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2015-06-11
Channels
- # admin-announcements (96)
- # beginners (102)
- # boot (51)
- # clojure (234)
- # clojure-art (1)
- # clojure-berlin (6)
- # clojure-brasil (1)
- # clojure-china (1)
- # clojure-germany (24)
- # clojure-italy (25)
- # clojure-japan (22)
- # clojure-russia (85)
- # clojure-sg (3)
- # clojure-spain (6)
- # clojure-uk (7)
- # clojure-ukraine (3)
- # clojurescript (108)
- # code-reviews (11)
- # core-typed (3)
- # datomic (6)
- # docs (13)
- # editors (121)
- # euroclojure (10)
- # events (2)
- # jobs (7)
- # ldnclj (77)
- # off-topic (27)
- # reading-clojure (8)
- # reagent (27)
- # robots (2)
- # slack-help (22)
I like re-frame and its subscriptions. However, I have been unsuccessful to convince a few friends of their value over cursors. Anyone have an opinion on using cursors or subscriptions (or using neither approach)?
I use subscriptions, they are fine. I've migrated to freactive.core rx
mechanics as the underlying basis for subscriptions because it has more knobs to control evaluation lazyness and more sane in notifying watchers than reaction
, which is critical to because I need to use non-Reagent renderers and like to use them with re-frame architecture.
My first attempt was to use Javelin cells, they are superior for description of derived data, but I had some problems to make them dynamic enough.
They force spreadsheet-like approach, which is fine per se, but forces some architectural decisions which I was not ready to make.
Subscriptions has two selling points: they help you to have derived data without a hassle and they are read-only, enforcing one-way data-flow.
because subscriptions provide very valuable thing over lenses — cutting evaluation of non-changed branches of your derived data graph
Awesome, I'm going to give freactive another look then! I haven't played around with it yet.
(ns example1
(:refer-clojure :exclude [atom])
(:require [freactive.core :refer [atom cursor]]
[freactive.dom :as dom])
(:require-macros [freactive.macros :refer [rx]]))
(defonce mouse-pos (atom nil))
(defn view []
[:div
{:width "100%" :height "100%" :style {:border "1px solid black"}
:on-mousemove (fn [e] (reset! mouse-pos [(.-clientX e) (.-clientY e)]))}
[:h1 "Hello World!"]
[:p "Your mouse is at: " (rx (str @mouse-pos))]])
(defonce root (dom/append-child! (.-body js/document) [:div#root]))
(dom/mount! root (view))
from this page: https://github.com/aaronc/freactive
Here's what I've got so far:
(defn home-page []
(let [mp (reagent/atom nil)]
[:div.container {:on-mousemove (fn [e]
(.log js/console "mouse moved.") ;; does not fire
(.log js/console e) ;; <- nil for clientX and Y
(reset! mp [(.-clientX e) (.-clientY e)]))}
[:pre (pr-str @mp)]]))
How to use facebook’s Fixed Data table with reagent. Thanks to @ul! https://gist.github.com/ducky427/10551a3346695db6a5f0
@escherize: Won't that need to be a form-2 fucntion?
(defn home-page []
(let [mp (reagent/atom nil)]
(fn [] <---- added
[:div.container {:on-mousemove (fn [e]
(.log js/console "mouse moved.") ;; does not fire
(.log js/console e) ;; <- nil for clientX and Y
(reset! mp [(.-clientX e) (.-clientY e)]))}
[:pre (pr-str @mp)]])))
derp, yes this was an obvious mistake, even with the updated function :on-mousemove
doesn't register
Isn't it on-mouse-move
?
Checking
Yep, replace :on-mousemove
with :on-mouse-move