Hacktoberfest 2026: những issue maintainer đã đánh dấu cho tháng Mười, đang mở và phù hợp người mới. Xem issue Hacktoberfest

Phoenix LiveView Phoenix.Sync.LiveView.sync_stream evaluation

Đang mở
#96 4 bình luận 0 reaction 0 người được giao Xem trên GitHub

Chưa có ai nhận issue này.

Đánh giá

Độ khó
5/5
Thời gian dự kiến
Hơn một tuần
Mức phù hợp với người mới
25/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Đình trệ
Công nghệ
elixir

Hướng nghiên cứu

Bắt đầu với các entry point Phoenix.Sync.LiveView.sync_stream và sync_stream_update được đề cập trong issue, sau đó theo dõi cách dead render, live render ban đầu, độ cũ của snapshot và tùy chọn limit được xử lý. So sánh hành vi quan sát được với dữ liệu ban đầu hiện tại được yêu cầu, dữ liệu dead render mới, việc làm mới snapshot có thể cấu hình và các giới hạn hoạt động đúng; issue không nêu tên các file hoặc test cụ thể.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

Hello 👋🏻

I'm evaluating Phoenix.Sync.LiveView.sync_stream in my Phoenix LiveView application. Particular use case I'm checking is notification stream - I want to display notifications and keep them up to date in the UI.

I'm using it in the "standard" way:

defmodule MyWeb.MyLive do
  use Phoenix.LiveView
  import Phoenix.Sync.LiveView

  def mount(_params, _session, socket) do
    {:ok, sync_stream(socket, :todos, Todos.Todo)}
  end

  def handle_info({:sync, event}, socket) do
    {:noreply, sync_stream_update(socket, event)}
  end
end

After playing with it for some time, I have these observations that surprised me.

  1. dead render always has no data in stream - it's not ideal in tests and differs from the original LiveView approach.
  2. initial live render stream has old (sometimes very old) data. It means there's a lot of catching up to be done on each page refresh (since I'm not using client-side caching)
  3. Limit query seems to be not working, it silently ignores it.

So my questions:

  1. Regular phoenix applications are being "mounted" frequently, on each page navigation. Currently it means each such mount is followed by a lot of catching up, which is visible in UI. I understand it's done that way to reduce database load, but it's not ideal. Is there an easy option to configure max snapshot age before it's refreshed?

  2. Is there a way to get similar behaviour to phoenix streams in tests? I'm asking about dead render having fresh data (without cache)

  3. Is there a way to respect limit query in the initial render? Phoenix.Sync.LiveView.sync_stream(.., ..,.., limit: 10) doesn't seem to work.

In general, I have a feeling that sync_stream is promising, but not yet battle-tested utility. Which is a shame.

What I was hoping for:

I would love a solution that would work in the same way as "stock" phoenix live view streams

  1. initial data is always "current", present for both dead and initial live render, so there's not a lot of catching up, with limits working
  2. I don't have to "babysit" these streams with lots of pubsub broadcasts and subscribes, it would just stay synchronized out of the box.

All in all, I'm rooting for this project! It's really impressive how it's all working, just wanted to drop my own observations.

Ngôn ngữ chính
Elixir
Star
290
Fork
18
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Chuẩn bị môi trường

  • Có Dockerfile hoặc tệp Docker Compose
  • Không có mẫu pull request
  • Không có hướng dẫn đóng góp

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của electric-sql/phoenix_sync

Tất cả issue của electric-sql/phoenix_sync

Issue tương tự

Thêm issue về Elixir

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.