In order to learn Phoenix, I’ve re-developped a backend (api) application which now runs OK with my frontend (node + vue.js) app.
Now, next step in learning (LiveView, this time): I want to get also rid of this frontend app by using LiveView instead.
Do you know some web pages or docs which could give me some clear guidelines, step by step if possible, to add LiveView to an existing api Phoenix application ?
As far as I can see the question was to just learn Live View, which is fine on itself right? no other reasons needed.
But in the real world this would not even be such a weird choice to do as you will (in most cases) empower a single team (or even a single person) to move across the whole stack again instead of doing handovers to frontend teams. A lot of companies struggle with this (handovers, ownership of both parts of the code). So while I agree this ‘decoupled design’ can give you flexibility, from another perspective it can also give you even more flexibility if it’s possible to keep everything inside one team, 1 repo and 1 language+framework (and have less code, dependencies and less knowledge to constantly keep up to date, easier (and a single) deployment target). That said, the use case should still fit live view, we have to avoid 1 hammer, everything’s a nail . (I believe Chris McCord was pretty clear on this, LiveView vs SPA fit different problems/use cases, but in the majority of the use cases they have seen with their company that live view would be a better fit than a full blown SPA).
The only thing i can come up with given your question is to have your codebase really well structured in the form of contexts. As in; is it possible to drive the app from your IEx console? (only through your contexts) If the answer is yes, then it’s pretty easy to ‘move’ to a live view based app. If not then I think you have to refactor to this kind of architecture. More info about this kind of architecture can be found in this pragprog book: https://pragprog.com/book/jgotp/designing-elixir-systems-with-otp
If you have your code structured in the above mentioned way it should be possibe to have them both next to each other. (API+SPA and LiveView variants next to each other).
Maybe als good to mention that this is just good programming practice and not specific to LiveView.
And yes: the “one language only” aspect is very attractive for me (especially if this language is Elixir ): I’m a bit tired of the JS boilerplates (far too many layers of librairies, frameworks and such) just to achieve only half of the work .