I am wondering whether I miss something in my understanding of Liveview.
By running a typical mix phx.gen.live Context Resource resources name:string, I navigate to the http://localhost:4000/resources URL and I “toggle” between the “New Resource” button and an escape (moving back without adding any new resource). All code is automatically generated.
By doing the aforementioned toggling, the generated network traffic demonstrates two messages of size 10KB and 8KB approximately, repeatedly as I toggle.
I am wondering whether this is the way it is supposed to work, since I thought that showing and hiding a modal is supposed to be client-side only.
On a second relevant aspect, the size of the page (HTML) that is generated after adding some new resources (even having only a single attribute such as name) gets significantly larger, though the actual presented information is really minimal. In this particular example, every new Resource item adds about 2KB in the size of the generated page.
Concluding, although I am really enthousiastic with the Liveview development experience, I am puzzled with the generated traffic over the wire.
What are your thoughts and solutions to this?
P.S. For the record, I employ the latest versions of Phoenix (1.7.1) and Liveview (0.18.16) and the generated code uses streams.
The temporary assigns are supposed to be replaced by the newest “stream” functionality. This could be related to some degree with the second aspect of my concerns above. However, even in view of that, requiring around 2KB merely to display a name (certainly in a hypertext format) is more that what I would have imagined.
Notwithstanding this, the first experiment mentioned above, involves no actual assign variables, i.e. in the experiment I have not added yet any resource, hence, it shall correspond to an empty list (I imagine).
That may be one reason, and you can extract it to classes if necessary, but JS commands are also part of it. We were working on tiny improvements to reduce the amount of commands which will probably make it to the next version as well.