Fork me on GitHub

I think it could be valid, if you either want less dependencies, or not one global state


@sandbags @gklijs I always have the same response :-) You can absolutely use Reagent by itself if your application is simple enough. BUT if you just use Reagent by itself then you only have the V bit of an application. As your application starts to get more complicated, you *will* start to create an architecture which adds control logic and state management - the M and C parts (even if you don't think you are, you are). So then the question becomes: is your architecture better than re-frame's or not? And some people prefer their own architectures and would answer "yes" :-) Fair enough. I think the only danger arises if this process is not conscious - if someone creates a dogs breakfast of an architecture and doesn;t even know they've done it. I've had MANY people privately admit that's what happened to them ... and then they swapped to re-frame to get some structure back. So, my advice is .... if your application is a little more complicated, be sure to make a conscious choice around architecture, because one way or another you'll be using one.


@mikethompson good point, for a very basic website, I now even use neither, since even reagent feels like doing to much.


@mikethompson i was talking to @danielcompton about the gitbook docs, is there any reason why you're not using such a tool ? 🙂


@lxsameer No real reason other than ignorance :-)


I'd very much like to improve the presentation of the docs


For example, I'm painfully aware that "a line" of text shouldn't be wider than 70 chars for a good reading experience, etc


@mikethompson i converted the re-frame docs to gitbook, to use the epub 😛 , if you're cool with it I can take care of it


I'm certainly interested. But also cautious. What does it look like?


@mikethompson let me show you a screenshot


@mikethompson we can change the theme really easy


but it's the default one


I think that looks better than what we have


Is it hard to build ?


Tool chain wise


I'm on Windows


Hmm. gitbook looks commercial. But I assume they do something free for open source?


Gotta go. But I'm cautiously interested.


it would be easy to create a new theme ( there are plenty of them we can use )


and there is no need to use the commercial service, I done that locally and also we can use the free plan since re-frame is opensource


but in general it's quite satisfying, I'll make a PR later


converting the re-frame docs to gitbook would be great! @daiyi I think this thread might be interesting to you!


How do you provide the session login state to re-frame view components via a subscription? I could imagine querying an api and storing the result in the db, or maybe adding a non-http only cookie, but my feeling is those aren't the most elegant ways to accomplish that. (Currently the authorization is done via buddy with a ring session backend)


I have the following situation: component subscribes to sub1 click-handler dispatches event ev1 ev1 does optimistic update to db, sub1 should be refreshed and component should be updated ev1 also dispatches ev2, which does a URL navigation which triggers secretary to dispatch another event to do a request, eventually also updates sub1 the optimistic update doesn’t work, but when I comment out the dispatching to ev2 in ev1, it does work. What could be wrong?


@borkdude could you provide the code for your ev1? I'm suspecting that you've got the ev2 dispatch in the tail position of your ev1, meaning that you're not returning your updated (with the optimistic update) app-db from ev1.


@U0AQ3HP9U Thanks. However, that’s not the issue. Code looks like this:

 [(path db/page-id)]
 (fn [{:keys [:db]} [_ current-guid new-guid route]]
   (debug current-guid new-guid)
   (debug "OPTIMISTIC event" new-guid)
   {:db (let [article (get db ::db/article)
              article (assoc article :optimistic-guid new-guid)]
          (assoc db ::db/article article))
    :navigate route}))
where :navigate is an effect which navigates to the route


Lots of stuff going on there, with some re-frame API usage that I'm not used to reading


let me just see if I can understand it


looks fine to me, but I don't have any experience with -fx event handlers


so I don't know any particular traps in that area


is everything in the "call chain" of events and subs following the :navigation fx called correctly?


It seems to work with dispatch-sync


well, good! I have no idea why that would be.


I don't know how dispatch-sync affects your event chain, or even if it does, apart from the first event


I didn't change anything in the docs yet, we might need to change some minor stuff , like adding a cover or some image urls but in general it would be like this


also adding a new theme is as easy as adding it to docs/build/book.json file


let me know you thoughts on this


Maybe this is what I need dispatch-sync for, it seems to work that way


@mikethompson do you have any idea of why that would be? dispatch-sync working for @borkdude in this situation, I mean


I can't grok it from reading the docs on dispatch-sync


@vinai storing the session login state in app-db makes all the sense. Why do you feel it is not "elegant" ?


Because I think I'll have to make an extra api call probably. Something like Login post -> Route captured by server -> redirect to route captured by frontend app -> query API to update login state. Hm, maybe not. I guess I can make the login post via ajax.


Sorry, I guess it was a stupid question. I'm not very bright today #tired


certainly... pretty much everything on a reagent/re-frame app will be via "ajax", and you simply update the db on response


you still need something like local-storage if you want to remember the user's auth info across browser windows (or tabs)


I'm persisting big parts of the db in local storage already, so adding the login state will not be an issue.


@borkdude not sure I fully understand but ... thoughts ... > ev1 does optimistic update to db, sub1 should be refreshed and component should be updated Remember that (Reagent) component refreshes happen in the next animation frame. Potentially up to 16ms from "now". In the meantime, that further dispatch may have been processed Use of dispatch-sync might nudge the timings so things happen in a different order. Ie. there might be an animation frame already scheduled for 1ms from now, and by using dispatch-sync, the component refresh (together with subscription refresh) might happen "this cycle" (in 1ms) rather than "next cycle" (17ms) of animation frames. Or something


Is there a way to prevent a sub from getting disposed of when the watching component gets unmounted?