didus

didus

Temporary assigns with streams causes the order of items to be reversed when prepending

Hi,

We have a page where we display events to users that relies on infinte scrolling. We decided to migrate from the old phx-update and temprory assigns fashion to LV Streams to leverage the :reset option to be able to clear the page when user makes a search with no results and everything works fine. Howerver, we are facing a strange issue when prepending new events with the option at: 0 of the stream function. This causes the order of items to be reversed on the client side ! the DB request does its job well with the right sorting order so why this option is reversing the order ? is it the normal behavior ? note that we didn’t have this issue before (with phx-update="prepend") and as a workaround is to use Enum.reverse() function :

stream(socket, :events, Enum.reverse(new_events), at: 0)

Thanks for your help

Most Liked

sodapopcan

sodapopcan

Streams have had a few problems which have been actively worked on recently. This should already be fixed in LiveView 0.20.4 which will be released soon. Try using main and see if you still have the issue.

Also, welcome!

steffend

steffend

Phoenix Core Team

Well it could be, but I’ve been discussing this with Chris and José and the decision was to document it. Internally this is implemented as a reduce calling stream_insert on the items, so the decision was between making a special case or just documenting it. You can add your arguments to the PR though. It’s not accepted yet :smiley:

Where Next?

Popular in Questions Top

Patoshizzle
After calling mix ecto.create I get this error: 17:00:32.162 [error] GenServer #PID<0.412.0> terminating ** (Postgrex.Error) FATAL...
New
minhajuddin
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
dokuzbir
Hello, I am trying to convert my lists to string without losing brackets.For start i have 3 map. They look like these buyer = %{ id: ...
New
nsuchy
Hi. I’ve noticed that Windows Powershell has it’s own IEX command and you cannot access Elixir’s IEX due to the conflict. This isn’t a cr...
New
script
If I have a string “1000 cfu/ml” . I want to remove the characters and / and space . So the string is like this "1000" What is the ...
New
alice
Hey, Just curious what are the main benefits of Elixir compared to Clojure? When is Elixir more useful than Clojure and vice versa? Th...
New
shahryarjb
Hello, I have map which I want to convert it to string like this: the map: %{last_name: "tavakkoli", name: "shahryar"} the string I ne...
New
LegitStack
I’m trying to make a websocket server in Phoenix or raw Elixir. I heard about gun, I think I could use cowboy, but since I’m not that sma...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
WestKeys
Currently suffering from paralysis by [HTTP client] analysis. This is rather unusual in Elixirland as there tends to be consensus on the ...
New

Other popular topics Top

yurko
Here are few pieces of (common) Linux knowledge that we use for reasonably small one server apps. We use Ubuntu but this should work for ...
New
vonH
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New
lessless
I believe there are people here who are dealing with CSV files import on the daily basis, and since Excel is a really popular tool there ...
New
axelson
This post is a wiki (feel free to hit the edit button near the bottom right of this post to add your own changes!) This post collects co...
239 45766 226
New
ycv005
I have followed this StackOverflow post to install the specific version of Erlang. And When I am running mix ecto.setup then getting fol...
New
New
aadeshere1
I have a another noob question about loop. Since elixir is immutable, while loop is not directly possible. total = 10 while total != 0 ...
New
chensan
I have a User schema with a :from_id field set to type :string: defmodule TweetBot.Repo.Migrations.CreateUsers do use Ecto.Migration ...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New

We're in Beta

About us Mission Statement