This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2016-01-27
Channels
- # alda (21)
- # announcements (7)
- # beginners (70)
- # boot (95)
- # braid-chat (28)
- # bristol-clojurians (2)
- # cider (22)
- # clara (4)
- # cljsjs (13)
- # cljsrn (40)
- # clojure (93)
- # clojure-argentina (1)
- # clojure-art (1)
- # clojure-miami (3)
- # clojure-norway (1)
- # clojure-portugal (2)
- # clojure-russia (39)
- # clojure-sg (3)
- # clojurescript (25)
- # clojurian-chat-app (4)
- # community-development (5)
- # conf-proposals (20)
- # cursive (48)
- # datomic (39)
- # devcards (5)
- # dirac (4)
- # editors (2)
- # events (11)
- # funcool (65)
- # hoplon (95)
- # jobs (12)
- # ldnclj (4)
- # lein-figwheel (2)
- # leiningen (1)
- # om (311)
- # onyx (20)
- # philosophy (4)
- # proton (41)
- # re-frame (83)
- # reagent (49)
- # ring-swagger (3)
- # spacemacs (8)
- # yada (5)
also I am not sure why todos are dereffed since :todo-dynamic doesn't seem to return a reaction
Is it correct to say of a Form-2 component, 1. the inner render function is called again when an atom that was deref'd inside it, changed since the last call 2. the outer function is called again when the function argument values are different from last time
Outer is called on component mount, to create a new instance of component, with render function being the function returned by the outer function.
So the inner function is called when a new real DOM is needed because props/ratoms/state changed.
Outer function is called, when the virtual DOM structure changed by adding a new component.
https://github.com/Day8/re-frame/wiki/Creating%20Reagent%20Components#form-2--a-function-returning-a-function seems to be suggesting as much as well
Hmm, so the outer function isn't called again when the function argument values change. Then I wonder how https://github.com/yatesco/re-frame-stiching-together/blob/master/src/cljs/demo/views.cljs#L161 works. cc @colin.yates . Ah, it works only because attaching the key in https://github.com/yatesco/re-frame-stiching-together/blob/master/src/cljs/demo/views.cljs#L78 leads to a different component instance. That seems cludgy.
hi @mbertheau - I haven’t used re-frame for a while and that repo was a ‘discovery-at-the-time’ so not much to add unfortunately.
and yes, adding a key
is a hack
react is expecting a key to be able to render only a specific component more effectively
anyone tried to expose local state in re-frame apps?
I want to inspect and serialize all local state
Would dispatch-sync
a [:create-local-state key]
inside a [:local-state key]
subscription be something not great?
I made a component to pr-str what I pass to it and I just inspect stuff like that when I'm in development phase
I mean exposing form-2 local atoms
To have some state that is scoped to a single component, but is accessible from serializers
much like om component's state
@yenda: how do you do that btw? I’m having trouble understanding how to approach persisting app-db across reloads and such.
I do it in a really hacky way atm, just printing it in the console and copying the result in the default-db
but when I will want to persist it properly I will just send it to the server and store it
True, but I thought you were talking about local state; doesn't sound like something you would want to persist server-side.
my app has a great number of forms
I don't want to hide input values inside local states
I will think about this better
maybe what I want isn't a way to expose local state, but to hold initial values and edit values
@hugobessaa: How many forms are you talking about? I've tried a few different methods but might be at a much smaller scale.
i'm talking about maybe a hundred
not simple ones
it's a saas for companies hr
Is the data loaded from a server when you browse to one of them or is it all held locally?
loaded from the server
Ok, what I did might apply but it works for us on a much smaller scale.
In my app db, I've got :page-state {}
and :editing {}
, and each time I browse to a new form the values are blown away and populated for the current form
I've tried with 1 map per form but this seemed to do everything easier. When the form is submitted it sends over the values from :editing, and on success I just grab the current server values - one extra round trip didn't make any real difference for our app and made it much simpler
Then each form has a name, and I've got :main-panel
defined that just takes a keyword of that name.
Which then determines what form I'm in
Did I explain that in a way that makes sense? It's worked pretty well for me, can do both simple and complex pages with reasonable ease, but I don't have as many forms as you do
@mbertheau: do you understand dynamic subscriptions now, or is there something still unclear?
@shaun-mahood: Nice! I will be looking into a way to simplify form data loading and editing states. Thx
@shaun-mahood: as I have multiple forms per page, and want to persist editing state even before reloading, I will store them inside maps :)
@danielcompton: thx! Already read everything in the wiki but it always nice to read again
@hugobessaa: It gets a bit complicated, I did the same thing for my more complex pages too. It was my first experience trying to work with more deeply nested data structures, which was definitely a learning curve, but overall it worked pretty well for me
I'm solving some pretty nice problems. I will share my learnings
I really tried to make it so that I can just look at my app db and see the whole state that I care about, it really brings so much value having such easy debugging
@hugobessaa: reading that again, if there’s data that you want to access from other components that is currently component local, you probably want to move it into app-db
@danielcompton: I want "after" middleware to read them and instrument for debugging and persisting
https://github.com/Day8/re-frame/wiki/Debugging will let you trace values and computation, you could probably mod it to persist them too?
@hugobessaa: Not sure if it would work for your purposes at all, but I've also experimented with adding a sort of :history
map to my app db to keep track of how things got to where they are - I just dispatched twice on the specific things I cared about. Not sure the idea totally made sense, but it might help if you're only looking for a couple specific things
@danielcompton: yep, totally possible
Sounds like you're doing something interesting though, which is pretty cool especially as HR forms are about the most boring thing I can think of
@shaun-mahood: not for this use case, but yep for others. I will have "transactional data" and "committed data". Maybe other stages like "locally committed" and "server committed"
Will think about this. You pals helped me a lot to think deeper about this
Oh those are good categories to break into - I especially like knowing the difference between locally and server committed.
The whole point of that saas I'm working on is to make it less boring and give better data to HR people
Sounds like a good idea, based on the HR programs I've looked at it's pretty needed.
Specially here in Brazil
An unsolved problem for sure
Re-frame has been essential to control incidental complexity
Yeah, I'm a big fan of re-frame.
I implemented an employee directory with search, pagination, sorting, visualization and filtering. Went great. But I got worried after creating too much page specific state.
I had to start over from scratch a couple of times on a small app to really figure out how to use re-frame in a way that worked well for me, but each time I started over I understood so much more about how it worked. It was also my first Clojure project, so that added a bit of extra learning overhead.
Anything open source? Share what you learned :)
Nothing open source unfortunately. I guess I should build and open source something based on it as an example.
Can someone point out what I’m doing wrong with this reaction? https://gist.github.com/heeton/1edc3d5f48d3bd9a9690
I have a “current-town” subscription, and if I update the db in a handler, bits of my view update fine. But the part of my view that involves filtering a subscription doesn’t update. I’ve tried using reactions in various ways but can’t seem to make it work
You can see the issue in this live demo - http://17c04073.ngrok.com/#