This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-07-19
Channels
- # aleph (11)
- # aws (1)
- # beginners (14)
- # bitcoin (1)
- # boot (41)
- # cider (6)
- # cljs-dev (1)
- # cljsrn (13)
- # clojure (138)
- # clojure-italy (10)
- # clojure-nl (1)
- # clojure-poland (2)
- # clojure-russia (62)
- # clojure-sg (2)
- # clojure-spec (31)
- # clojure-uk (51)
- # clojurescript (109)
- # core-matrix (1)
- # core-typed (1)
- # cursive (63)
- # datomic (10)
- # emacs (9)
- # euroclojure (1)
- # hoplon (112)
- # immutant (16)
- # jobs (2)
- # lumo (5)
- # off-topic (14)
- # om (54)
- # onyx (17)
- # parinfer (23)
- # pedestal (2)
- # re-frame (41)
- # ring-swagger (23)
- # spacemacs (9)
- # specter (10)
- # uncomplicate (5)
- # vim (1)
how does one work with cells that have sequable elements ? like [{:name 1} {:name 2}]
(for-tpl [{:keys [name]} (j/cell= [{:name 1} {:name 2}])] (div name))
@avabinary
does that work for you?
(for-tpl [n (j/cell= [{:name 1} {:name 2}])] (div (j/cell= (:name n))))
or this?
(defc app-state {:modules {}
:choices {:top nil :bottom nil}}
:users-to-edit {})
(defn path-cell [c path]
(cell= (get-in c path)
(partial swap! c assoc-in path)))
(def all-users-cell (path-cell app-state [:users-to-edit]))
(case-tpl route
:users (div "users")
:edit-users (user-edit-view all-users-cell ))
(defn get-all-users []
(ajax-request {:uri "/api/users/"
:method :get
:handler (fn [[ok response]]
(if ok (dosync
(reset! all-users-cell response))
(.error js/console (str response))))
:format (json-request-format)
:response-format (json-response-format {:keywords? true})}))
and with secretary I defroute
(defroute "/edit-users" []
(dosync
(reset! route :edit-users)
(reset! all-users-cell (get-all-users)))
and user-edit-view that's called in the case-tpl is imported from a different ns
(ns admin.edit-users)
(defelem user-edit-view [_ users]
(for-tpl [n (cell= users)]
(div (cell= (:user_id n)))))
@avabinary con confirm PR #36 fixes all my issues 😜
@avabinary it’s your all-users-cell
is passed as children to your defelem
you need to specify some attribute :my-users-cell
or something
@flyboarder I previously passed it as an attribute and destructured in the receiving defelem
when I (cell= (pr x))
it would show up as [Object object] and when trying to loop-tpl or for-tpl it would Error on not implementing ISequable
@avabinary that would be the correct process, the non iseq error is probably because something was expecting a list
You probably want to wrap your destructured data within another cell
well ... I'm having this as a response
[{:name "Anna" :id 1}{:name "Costanza" :id 2}....]
also, I'm not sure I understand what you're proposing, you mean I should do a (defc received-users [])
and i (reset! received-users all-users-cell)
when I (cell= (pr received-users))
this is what I get #<Cell: #object[Pd [object Object]]>
when I (for-tpl [x received-users] (div (str x)))
i get Error: [object Object] is not ISeqable
@dm3 but when should I deref and when not ? because I have working code that does (reset! old-cell new-cell)
but I've run out of options and I thought that was what @flyboarder suggested
(:require [ajax.core
:refer [GET
POST
json-request-format
json-response-format
ajax-request]]
they're from https://github.com/JulianBirch/cljs-ajax/(defroute "/edit-users" []
(async/go (dosync
(reset! route :edit-users)
(reset! all-users-cell (async/<! (get-all-users))))
should I change the :handler for the get-users-cell as well or is it enough to change the defroute area ?
@avabinary you deref a cell when you want its value, otherwise you always use cells/formula cells
Correct, however that doesn't guarantee anything is mutated, it's just attempts to do what the lense callback does, which "should" update something
Usually an underlying cell to the lense
Which would cause the lense to also update
Also you can use anonymous cells within a defelem to see what happens as they update
Once you do, there will be no turning back!
I put [org.clojure/core.async "0.3.443"]
in my build.boot :dependencies
and then in my ns I required [cljs.core.async :as async]
That error is very accurate, you are usin <! Outside of go
There ya go!
Is there a repo?
@avabinary or post the problematic file