Fork me on GitHub

So SPAs seem like a bit of a pain. Is there a tutorial along the lines of “if you grew up on Rails, this is how you’d organization an SPA.”? For some reason, I’m having some difficulty thinking about how the views/data are managed. Most examples are too trivial to give much insight.


I mean it doesn’t literally have to be Rails, it might be a conversion of a multi-page app with REST URLs to an SPA. Otherwise, I’m inclined to give up and just do an MPA.


I am not sure how an SPA relates to Rails? Rails is purely backend, isnt it?


@actsasgeek: I've been using re-frame and generally have been able to do the views and data very similar to how I would in an MVC style application - there are some differences, but it's more a matter of having the flexibility to choose other models when it makes sense (my background before Clojure was http://ASP.NET MVC, which I believe is reasonably similar to rails). If you have a specific example of what kind of thing you are looking to convert, or something that is giving you trouble, I'd be happy to work through ideas with you.


thanks. I have to think a bit more about what it is that’s a stumbling block for me.


@actsasgeek: I had the same type of problem and found it pretty hard to communicate exactly what I was struggling with, and one day it kind of clicked - I think it was mainly finding that same mapping you are looking for in a way that made sense. Have you got a particular SPA library you are thinking of using or is it more of a general desire to get more rich interactions on top of what you are doing now? If you haven't looked at it, you might find helpful to get a starting point.


I have the book. My main problem is that it doesn’t quite go into the next “OMG” step.


In a RESTful MPA, we have /users, /products, /orders, /suppliers, etc. and each one has a view…it’s really always the kind of same master/detail pattern plus some AJAX for editing in place maybe if you want to get fancy. You have views, partials, the controllers, etc.


With Compojure, it’s kind of obvious how the server side is managed.


and for an MPA, you can basically do the same client side as you would normally do (with, say, Selmer).


but if you use say, just vanilla Reagent, most examples have everything there in the one page…it doesn’t show switching views from customers to agents, how to handle sorting, editing (is it always a modal pop up). I think that things like secretary and accountant get involved but ¯\(ツ)


@actsasgeek; Ok, definitely check out that - it's built on top of reagent and makes it pretty easy to get that part going. @yogthos has a good app to use as a getting started example at that has routing and everything in it as well.


the re-frame lein template is also a decent example of how to do the above


I actually looked at memory-hole this morning. The main problem I had was that is nothing that describes how it’s wired up. Maybe it’s more obvious if you understand re-frame better.


Yeah, some understanding of re-frame is definitely required - there's a very good intro video at that covers the basics well, and the docs are decent (though I've done a bit of work on them so I may be biased), and if there's anything that's unclear to you the #re-frame channel is very helpful.


I should probably do a post on how memory hole is put together, sounds like it could be useful


cool, thanks.