Saturn icon indicating copy to clipboard operation
Saturn copied to clipboard

[WIP] Live components

Open Krzysztof-Cieslak opened this issue 5 years ago • 3 comments

So... this is initial implementation fo Live Components. Inspired by Phoenix Live View they are designed to enable rich, real-time user experiences with server-rendered HTML. Under the hood, they're powered by our current channel implementation - essentially liveComponent is specialized channel.

What is different from Phoenix Life View is that Live Components implements MVU pattern. Essentially each component is small MVU application (it has its internal state and event loop), all operations known from MVU - init, update, view - are performed on the server, and after the view is rendered we push it to the client through web socket - this will then be used by some JS diffing library to update the DOM. Similarly to MVU, we define 'State and 'Msg types that represent state and actions in our component - both are defined on the server side

In current shape, PR is not usable at all, but it shows the basic design of server-side of liveComponent.

Currently missing:

  • Registering liveComponent in the application
  • View helpers (attaching attributes to HTML tags defining events, or the fact something is liveComponent)
  • Client-side (JS) library responsible for communication
  • Static rendering case. liveComponent first render should be static (i.e. send as part of normal HTTP response) and real-time communication kicks in after it - this will enable fast first rendering and SEO etc

Closes #228.

CC: @panesofglass @Banashek @baronfel

Krzysztof-Cieslak avatar May 21 '20 18:05 Krzysztof-Cieslak

Outstanding!!!

panesofglass avatar May 21 '20 19:05 panesofglass

@Krzysztof-Cieslak @Zaid-Ajaj This looks interesting. Should this get implemented? I think only the refactoring of the LiveComponentBuilderState is missing right?

tforkmann avatar Jan 15 '22 14:01 tforkmann

@tforkmann, there's also a client-side component (i.e. JS library) that probably we should provide to make it easy to use in practice. And add helpers for actually using this client-side library in the server-side rendered code to define communication between client and server.

Krzysztof-Cieslak avatar Jan 15 '22 18:01 Krzysztof-Cieslak