This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2020-03-25
Channels
- # announcements (8)
- # aws (50)
- # aws-lambda (6)
- # babashka (25)
- # beginners (119)
- # bristol-clojurians (5)
- # calva (25)
- # chlorine-clover (23)
- # cider (6)
- # cljs-dev (125)
- # clojure (63)
- # clojure-austin (1)
- # clojure-belgium (1)
- # clojure-dev (48)
- # clojure-europe (11)
- # clojure-italy (2)
- # clojure-nl (5)
- # clojure-spec (3)
- # clojure-uk (66)
- # clojurescript (14)
- # core-logic (5)
- # datomic (13)
- # emacs (10)
- # events (2)
- # fulcro (37)
- # graalvm (11)
- # hoplon (95)
- # jobs-discuss (9)
- # juxt (11)
- # kaocha (16)
- # meander (13)
- # off-topic (24)
- # pedestal (4)
- # re-frame (36)
- # reagent (10)
- # reitit (15)
- # ring-swagger (5)
- # shadow-cljs (23)
- # spacemacs (2)
- # sql (13)
- # tools-deps (32)
- # xtdb (11)
Hello everyone! I'm trying to, in a click of a span, replace the field from span to a input.
(defn input-text-brio-nr [brio-nr]
[:input {:type "text"
:value brio-nr
:on-change #(reset! brio-nr (-> % .-target .-value))}])
(defn brio-nr-formatter
[brio-nr]
[:span [:a {:on-click #(input-text-brio-nr brio-nr)} brio-nr]])
On my first attempt, it does not work as expected. So have someone tried to do this?
I'm using the brio-nr-formatter
on a re-frame datatable
(defn show-table []
[t/table
:ogm-table
[:ogm/search-results]
[(t/column {:key [:customer]
:label (ml/tx "Customer")})
(t/column {:key [:policy]
:label (ml/tx "Policy")})
(t/column {:key [:term]
:label (ml/tx "Term")})
(t/column {:key [:settlement]
:label (ml/tx "Bruto")})
(t/column {:key [:brio-nr]
:label (ml/tx "Brio Nr")
:render-fn brio-nr-formatter})
(t/column {:key [:brio-nr]
:label (ml/tx "Verified")})]])
Why not having an if in your view to either display the input or the span based on some arbitrary value you set in the state. Something like edit-mode?
I ended up doing that. Thanks
Now, what i'm trying to do it's the reverse. When i change the focus on the field, it will back to be a span
I did that, but it's doing in all of the columns and not in only one
That’s because when you save the edit-mode? Value in your state, the path you choose in your map has to be unique. You can save it for example under {:edit-mode? {“unique-id” true}}
So when your state changes and the table is rerendered, only one single cell will effectively become an input and not all of them :)
Do you know how can i send the id of the object or more data into the render function?
I was looking on documentation yesterday trying to do that
And also, a huge thanks for the tips
Found it
thanks a lot
(defn input-text-brio-nr [brio-nr]
[:input {:type "text"
:value brio-nr
:on-blur #(rf/dispatch [:ogm/set-edit-brio-nr false])}])
(defn brio-nr-formatter
[brio-nr cust]
(let [editing (rf/subscribe [:ogm/edit-brio-nr])
cid (:customer-id cust)]
(println "this is cust" cid)
(if @editing
[input-text-brio-nr brio-nr]
[:span [:a {:on-click #(rf/dispatch [:ogm/set-edit-brio-nr true])} brio-nr]])))
I got the id, just thinking in how implement your idea of unique way
You can pass cust
to your dispatch function and save the true
boolean under for example:
(assoc-in db [:edit-mode? cust] true)
and in your subscription you get the current mode out like this:
(get-in db [:edit-mode? cust])
Also, pass cust
down to the input as well. Its on-blur event will take cust
and will do:
(update db :edit-mode? dissoc cust)
Thanks, i'll give a try
So yeah you can simply call in your :render-fn a wrapper that returns your span or input depending on a re-frame subscription
Hello there, I'm trying to do some Web-Socket communication, and there seems to be a bottleneck somewhere. Ideally, I would want to send 1000s of requests and get 1000s of responses within a few seconds. Google says it should be possible with a million so thousands are probably not science fiction. Now, here is how it works: 1. Each requests starts by dispatching an event that triggers a :ws-send effect, 2. When a response comes through the socket, it triggers a :proscess-response event. 3. This :process-response event converts the response to edn and triggers another event :ws-command
4. :ws-command finds out from the data which db event to dispatch. 5. and this final event updates the app-db with the data we got from the response.
Now, this is maybe a little rube-goldebergesque, but I'm not sure what influences performance the most.
How do folks generally organize their namespaces as a re-frame codebase grows? I have all my view code under a my-project.components.*
umbrella of namespaces, but wondering about other stuff. The re-frame template defines my-project.subs
and my-project.events
, but as it grows I think I will need to break down each into features/component groups, while still keeping the event/subscription keywords in the higher-level namespaces, like this:
(ns my-project.events
(:require
[my-project.events.locations :as locations]
[my-project.events.providers :as providers]
;; etc.
[re-frame.core :as r]))
(r/reg-event-fx ::search-locations! locations/search!)
(r/reg-event-fx ::search-providers! providers/search!)
This way I maintain a single entry point each for components into events/subs. Thoughts?I like having subs and events in one namespace related to the feature I’m working on
(ns my-project.locations
(:require
[re-frame.core :as r]))
(defn search! [] ,,, )
(defn update-results [] ,,, )
(r/reg-event-fx ::search! search!)
(r/reg-sub ::search-results update-results)
so something like that?I could see how that could be nicer...it's already a bit of a pain jumping between views/subs/events