Introduction to Phoenix LiveView
By James Moore
A couple years ago I was at the beginning stages of a new web project, and I was figuring out how I wanted to build the app. I felt like I had a pretty good understanding of what the requirements were, and initially, I was thinking I could build the app as a traditional MPA (Multi Page App).
Ok, building MPA's isn't cool or sexy, but it's way simpler than building SPA's (Single Page Apps), and I'm more productive with MPA's and in my opinion, these kinds of apps are easier to maintain... I mean, if you think about it, the jump from MPA's to SPA's adds a ton of complexity, and having to switch back and forth between a frontend and a backend language is a real cognitive burden.
Anyway, as I was thinking about how to implement the app, I was stuck on a couple small but important features that would be pretty hard to implement in a MPA, and I was thinking about some of the phase 2 features, and I started to question the viability of implementing this app as a MPA... It felt like a decision I might regret later, so I did what many of us have done, and I just built it as a SPA.
But honestly, this wasn't an easy decision... In building it as a SPA, I basically took on a bunch of complexity, just to have the ability to add "rich" features, which for the most part I didn't need.
In hindsight, I don't know if building this app as a SPA was the right choice. It took me longer to implement, and those future features I was worried about, were never added, and every once in a while when I work on this project, npm tells me I'm using a bunch of libraries that have vulnerabilities... so I have to spend a significant amount of time digging into the vulnerabilities, and resolving them, and of course it's a reminder that I should probably be more proactive in maintaining my apps, even when I'm not adding features.
It would be kind of nice if there was a middle ground between SPA's and MPA's... in other words, it would be nice if there was a way to build web apps with richer features, without having to take on all the complexity associated with SPA's... right?
Well, I've got good news, there's a new way to build applications that offer rich, real-time features without adding a ton of complexity.
Now, the solution I'm referring to is quite novel, and there's a good chance your first impression will be something along the lines of "This seems a little crazy"... Those were my first thoughts, but after learning more about it, and using it, I've become a believer.
So what is the new option I'm referring to?
If you're curious about Phoenix LiveViews, and you want to learn more, you should checkout this screencast I just released.
Now, LiveView only works with the Phoenix Web Framework, which is written in Elixir, but you don't need to know Phoenix or Elixir to watch this screencast... In fact, I made this video specifically for web developers who don't know Elixir (if you do know Elixir, I think you'll still find a lot of value in watching this video).
Ok, even if you have no intention of using Elixir or Phoenix, you still might want to watch this video, because it truly is a unique solution that I bet you'll find interesting, and I think exposing yourself to new ideas like this, can often lead to other creative solutions.
Want to learn more about Elixir & Phoenix?
Checkout my new course: Elixir & Phoenix for Beginners