This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2017-01-26
Channels
- # aws-lambda (1)
- # beginners (71)
- # boot (70)
- # bristol-clojurians (1)
- # cider (2)
- # clara (13)
- # cljs-dev (96)
- # cljsjs (6)
- # cljsrn (5)
- # clojure (74)
- # clojure-android (3)
- # clojure-austin (4)
- # clojure-dev (10)
- # clojure-russia (6)
- # clojure-spec (28)
- # clojure-uk (128)
- # clojurescript (64)
- # cursive (2)
- # datascript (18)
- # datomic (116)
- # dirac (1)
- # emacs (12)
- # events (10)
- # hoplon (109)
- # jobs (1)
- # jobs-discuss (21)
- # leiningen (2)
- # luminus (6)
- # off-topic (19)
- # om (21)
- # om-next (5)
- # onyx (4)
- # parinfer (29)
- # perun (20)
- # re-frame (53)
- # reagent (21)
- # remote-jobs (5)
- # ring-swagger (2)
- # spacemacs (6)
- # untangled (42)
- # vim (5)
on a scale from 1 to 10, how bad is the idea of storing Reagent components inside app-db? (1 - not so bad, 10 - worst idea ever)
are we talking about reagent components (pure functions) or the reified element (DOM element)?
pure’ish functions. I’m not sure that Reagent component that subscribes to some data via re-frame internally satisfies the definition of “pure"
I'd generally avoid both, clojure functions are compiled and if you print the app-db you'll see a huge JS blob lol
how about storing a view function name instead of a whole function and use some magic to render a component based on it’s name?
I kinda like a solution when as a result of routing dispatch I can store some :active-panel
key inside db, but I don’t like the fact that resolution of what should be rendered happens on a view level (via multimethods or case)
the reason for it is that when my active-panel
component is more complex then just current view (i.e. imagine a layout which has breadcrumbs, active view title, primary action/main menu for a current view, active panel itself) each of these components should have some kind of map between active-panel
key and what should be rendered
right, I currently have all my main views contain a header component that subscribes to :active-panel
but I'd love to see if there are better solutions too~
the solution that I’m trying to scribble is some kind of a map which maps route key to a pre-defined map of multiple things: let’s say title, API calls that should be made, views that should be rendered, list of containers for views that should be used as interceptors in order to make sure that make sure that result of all api calls is 200, data has been saved to db, etc.
in other terms, I want to create some kind of a sitemap datastructure, that maps route to everything which can be a result of this route (i.e. views rendered, data fetched, etc.) and reuse this sitemap to make decisions about redirects, POST API calls that should be done, etc.
if this kind of data structure is flexible enough most of the processing logic can be simplified to map lookup
that sounds interesting, do keep us updated~ 🙂 maybe it could even help pull in the right modules at compile-time...
has anyone found a good solution to query duplication as a a result of following the "Subscribe to an external datasource" pattern? This is described as the following sub (excuse pseudo-code)
(reg-sub
:people
(fn [{people :people :as db] _]
(make-xhr-request-for-people)
people)
Where make-xhr-request-for-people
queries an API and puts the results into the db
at :people
? I've solved it previously by only running that fn if -> db :people :loading
is false
/`nil` and setting it to be true in make-xhr-request-for-people
. I feel it could be done better with query de-duplication / memoization... curious if anyone has a pattern for this they likethat will create a constant loop
calls out to xhr should be reserved for handlers.
what are you trying to do with this?
can you link to the where in the re-frame docs it suggests this.
This kind of goes against the whole idea of pure functions for subs and ahndlers
yeah but you can isolate that in an http interceptor. https://github.com/Day8/re-frame-http-fx
also the example in the docs shows using reg-sub-raw that returns a reaction
that way it only runs the let binding once.
so the query only runs once.
hmm interesting, I haven't tried that, I've been using this approach since before the big change in .0.9 which I believe might not have had the reg-sub-raw
form
effects handlers are great, although i ended up needing to write my own http one based on a different client lib
you use reg-sub-raw here because you only want the query to run when the subscription is created.