📄️ LiveViewSocket API
The LiveViewSocket API is the second most important API (behind the LiveView API itself). As you've seen, the LiveViewSocket is passed into (as the socket param) just about all of the LiveView API methods (excluding render). So far we've mainly used it to update the context of the LiveView. But there is a lot more to LiveViewSocket and in this section we'll review the full API.
📄️ LiveViewSocket API - Context
The "context" of a LiveView is the current state of the LiveView. One way to think of a LiveView as a set of methods that handle events, read and write the context, and render a view based on the data present in the context. Obviously, properties and methods that manipulate the context are very important to a LiveView.
📄️ LiveViewSocket API - Push
There are various methods for "pushing" data from the server to the client outside of render and updating the URL of the LiveView.
📄️ LiveViewSocket API - Server Events
Server events are important to connect LiveViews with asynchronous processes. For example, a LiveView may need to wait for a long database query or search service to complete before rendering the results. Or a LiveView may want to send updates based on a webhook or action from another user.
📄️ LiveViewSocket API - Uploads
A common use case for a web application is to allow users to upload files. The following methods on the LiveViewSocket enable you to upload files to your server.
📄️ LiveViewSocket API - Misc
There are a few other methods and properties that are available on the LiveViewSocket object that we haven't covered yet.
📄️ Raw `LiveViewSocket` API
For your reference, below is the raw Typescript for the LiveViewSocket interface (copied from here):