Fork me on GitHub
#re-frame
<
2015-08-06
>
Pablo Fernandez11:08:48

How do you show the page is working, for example, when you are waiting from an ajax call, so that that one time it takes long it doesn’t look like the page died?

ul11:08:23

@pupeno: having marker in app-db? like :ajax-loading? and render smth special if true. set and unset in handlers

Pablo Fernandez11:08:27

@ul: yes, the marker is fine, although I’m slightly concern about paths that leave the marker on accidentally. But I mean, how do you normally display it? any reusable component? I don’t want to flash a spinner in the middle of the page for each ajax call, that can get annoying.

ul11:08:15

flash it in the corner, or use toatr, or what you like. another useful thing is to make :ajax-loading not boolean, but timestamp when set

ul11:08:30

you can wait a little before showing spinner

ul11:08:43

if ajax call is fast, nothing blinks

Pablo Fernandez11:08:00

@ul: yes, I gather I’m not the first one to want this, so I was wondering if there was something reusable out there for this.

ul11:08:52

i'm not aware about reusable, i just insert one-line conditional render in the places where spinner is to be

ul11:08:08

it is div with preloader class, everything else is done by css framework

Pablo Fernandez12:08:45

I’m starting with re-frame and I noticed this. I have a little address book that displays a list of people, so in the db I store a list of people and display it. This is loaded from the server on an ajax call. When you click on a person, the record for that person is displayed. I’m using secretary so I link to /#/person/john-doe and that dispatches to a handler that sets active-panel to :person-panel.

Pablo Fernandez12:08:01

But then I need to have, in the db, which person is being displayed. Right?

Pablo Fernandez12:08:55

My first though was: :current-person in the db, but as people move to other parts of the app, this would be left over and could interfere with other parts of the app that also have a current-person.

Pablo Fernandez12:08:07

So, it feels like {:people … :current-person} in the db has a mix of two things: :people is data retrieved from the server, but :current-person is something akin to current-pane-state. I’m thinking of putting it in :current-pane-state, so the next pane will nuke it. Does it make sense?

escherize12:08:32

maybe current person could also be something local to the person-shower view.

roberto13:08:44

I have a state per route. That way, I can reset the state everytime the route is triggered.

Pablo Fernandez14:08:59

roberto: what’s the advantage of state per route instead of state of the current route?

Pablo Fernandez14:08:09

escherize: what would that look like?

roberto14:08:44

I don’t understand what you mean by state of the current route…. but basically, I find it easier to reset the state of the route I’m going into if it contains its own state.

roberto14:08:04

so stuff like :is-loading? gets reset

Pablo Fernandez14:08:38

roberto: oh, are you talking about showing loading progress, not my last question about state.

escherize14:08:28

well, i have this form page with a lot of info for some item. I actually have a (subscribe [:current-item]) that gets cleared after the form gets filled out and does its job, but that could have been accomplished the same way using (r/atom {:item-attr "thing" .. }) since I didn't need the item info anywhere else

Pablo Fernandez15:08:05

This is not local to a form though. This is what the page should show based on the URL.

shaun-mahood15:08:43

Has anyone written anything up on how they have integrated re-frame with Secretary, Silk, Bidi, or any other routing libraries?

arathunku15:08:43

@shaun-mahood: are you looking for something specific? I've Secretary and re-frame working in a very simple side project: https://github.com/arathunku/game-fun/blob/605978790e358de990b028930cab51cf96f72fb6/tiled-mmo/server/src/cljs/tilet/routes.cljs#L10

shaun-mahood15:08:44

@arathunku: Not looking for anything too specific. I've got things working in Secretary but am not totally happy with it - seems like getting it to work nicely isn't as clean or easy as it should be and wanted to look at how others have done things. Trying to get it to work nicely with figwheel reloading, the initial load of app-db data from ajax calls (depending on which page is first hit and supporting bookmarking), and general route dispatch with links within the app.

arathunku15:08:09

Oh, ok. I probably should have written down how I've done it. I remember I had a problem with figwheel reloading and views refresh in reagent.

shaun-mahood15:08:50

I've got it mostly working, but there are some edge cases that I just find annoying and think will cause problems later down the road. Thinking I might have to spend a bit of time figuring it out, then get it working in each of the libraries and write it up for the wiki. Been planning on doing it for secretary but just not happy with my results yet.