AstonJ

AstonJ

We’ve put together this wiki for Phoenix LiveView - please feel free to add any info you feel is worth including.


What is Phoenix LiveView?

As described by @darinwilson “Phoenix LiveView allows developers to add dynamic, client-side interactions to web pages, using code that runs in Elixir on the server”. This mean you could kiss goodbye to front end frameworks like React and the JS-hell that so many of us have been finding ourselves in these past few years! As you might imagine, the community is very excited about this!

For a more in-depth explanation, check out Darin’s excellent blog post on the topic.

Official URL: GitHub - phoenixframework/phoenix_live_view: Rich, real-time user experiences with server-rendered HTML · GitHub
Original announcement: Chris McCord’s ElixirConf 2018 Keynote

Threads of interest:

Screencasts & Talks:

Podcasts of interest:

When can you get your hands on it?

Chris has said “soon after Phoenix 1.4 comes out” (and 1.4 is due out soon!). Edit: Now! Here: GitHub - phoenixframework/phoenix_live_view: Rich, real-time user experiences with server-rendered HTML · GitHub

Has there been anything like it previously? Has the idea been tried and tested at all?

We’ve put both of these questions together because the answer is yes and yes! There is a similar library in the Phoenix world called Drab, which has proven to be very popular in the community. LiveView tackles the same sort of problem but from a different angle - so if Drab is anything to go by, LiveView is going to be a huge hit :003:

There is also another similar library that was announced at ElixirConf 2018, called Texas.

There’s now another new library, called Morphling… and… another called Whistle :smiley:

Where can I get more details?

Chris McCord’s keynote is currently the best place to get details, followed by the blog posts on the topic as well as Chris and José’s comments in the numerous threads that have cropped up here on the forum.

Demos

https://twitter.com/chris_mccord/status/1059273315666350080?s=20

  • Blog post and another demo:

Showing Posts 31 to 40

chrismccord

chrismccord

Creator of Phoenix

debouncing will be part of the initial release for the delay/throttling of events

English3000

English3000

@chrismccord, 2 questions:

  1. Any plans for a LiveView linter (so that not everything appears green)? Would be nice to have.

  2. One place where React struggles is when one wants an event in a child component to “bubble up” to its parent. Basically, one needs to pass an action function (with a captured reference to the parent’s state).

    Alternatively, one can use Phoenix Channels (using channel events for actions–instead of REST–and setting channel event listeners throughout one’s component hierarchy, which can each modify their respective state in a unique way).

    Now with Phoenix LiveView, a new possibility is introduced: component message-passing.

    Because each component’s state is really just a process with some event handlers, if something happens in one component, just as it can send itself an event (as in your blog post’s examples), it could send an event to another component’s state process.

    In order to make these processes accessible, it would be easiest to register each with a name.

    Is that possible, and WDYT of this potential design pattern?

chrismccord

chrismccord

Creator of Phoenix

Do you mean for syntax highlighting? That would be editor dependent. Here’s my emacs highlighting with mmm-mode:

generic html.leex files are also supported like any other html.eex file.

wrt to messaging passing, you can use registry with the view’s unique ID to messaging b/w parent and children views. We don’t register them by default, but it would be a couple LOC to do it yourself. We’re going to wait a bit with messaging since it’s not clear what the best approach is. For example, ad-hoc messaging b/w react components is known to scale poorly architecture wise, but LiveView’s will likely be less complex so it may be fine.

cnck1387

cnck1387

Do you know of any open source examples that use Unpoly? It’s a pretty big library, but there’s really not too many tutorials written on their official site.

I wonder if there’s a way to only pull in a tiny aspect of it, although going by their docs, I’m not even sure what aspect I would use to pull in ajax content. I guess ajax.accel, but it’s also tagged as experimental.

vans163

vans163

I started working on a lightweight lib to do what LiveView does except without a dependency on Pheonix, because simply cannot wait for LiveView code to be posted to github, if anyone interested check it out GitHub - vans163/morphling: Server driven DOM morphing library. Never write Javascript again. · GitHub (forum thread)

ATM I wanna ask how LiveView does the DOM diffing on the server side? Its actually quite challenging to figure out how to send the differential between 2 binaries.

OvermindDL1

OvermindDL1

What tutorials are you needing? Unpoly.js is very piecemeal, only use what you need, and all the features have great documentation. If any of the documentation is lacking then I’d assume telling them on their github repo would be best, but I’ve never had an issue with the documentation as it seems quite comprehensive?

It’s an older style library sadly, not built using modern modules, though it looks like they are slowly moving that way.

zachgarwood

zachgarwood

I can’t find any information on the ~L sigil used here. Is this LiveView-specific? Where does it come from and what does it do?

cnck1387

cnck1387

Right, I wouldn’t want to bring in a 109kb library (the minified unpoly JS size on github) just for a few ajax calls since I imagine most of my other things (like video progress tracking, search autocomplete, etc.) could be done with liveview?

OvermindDL1

OvermindDL1

Sounds like you are a usecase to make PR’s to them. ^.^

cnck1387

cnck1387

Probably not haha. Unpoly is a massive ball of coffeescript and I already hate JS enough as it is.

I will have to use something though because liveview isn’t looking like a good fit to transmit 10kb+ of html between browsing tabs.

Where Next? Top

Trending in Wikis Top

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
jimsynz
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Dmk
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
netoum
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
webofbits
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself. My main conc...
#ai
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews