Phoenix LiveView and Pjax

Have anyone succeeded with Phoenix Live and Pjax (or other similar tool)? My point is that not all pages in my application require LiveView, but I would like it to not fully reload on each page change.

2 Likes

I think they should work together just fine. What have you tried?

3 Likes

Ok, found it. I needed to disconnect while unloading and reconnect after load of the new page.

3 Likes

I just started to migrate from Drab to pjax + LiveView. But currently LiveView is better suited for some use cases; updating a partial of pages interactively.

LiveView as a pjax isn’t ready since pushState is not supported. Turbolinks is actually more mature than LiveView in this area. Mobile support is as well. But in the long run I certain that the LiveView will replace the Turbolinks.

I do not think that LiveView is at all meant to replace Pjax/Turbolinks. LiveView is (IMHO) meant to be “single page updater” not tool to handle multi page updates and content. And in that form I think that having both of these technologies to cooperate is quite easy and painless, so I do not see the problem with using both of them at the same time to handle everything.

1 Like

So LiveView has no ambition to support SPA ?

I have no idea, but form what I understand it isn’t meant to be „full fledged SPA framework” but rather mechanism for supporting „live view” components on the website.

There have been two proposals so far, and the up to date one is here:

2 Likes

This response is based on information given by @chrismccord 's talk at ElixirConf.eu:

  • LiveView has some clear limitations. For instance, it will not be able to work when the user is offline. So progressive web applications are the kind of things that LiveView will not work for. (See also the final paragraph before the summary of Phoenix LiveView: Interactive, Real-Time Apps. No Need to Write JavaScript. - DockYard )
  • On the other hand, pushState-support is definitely something that will be added. Amongst other things because reflecting the state changes in the URL so that it can be bookmarked or shared is quite a common use case.
2 Likes

I’m facing a similar problem with LiveView and Turbolinks.
Would you mind sharing an example how you are disconnecting and reconnecting?

1 Like