loics2
I’m currently updating the lists in my app to live streams and infinite scrolling as describe in liveview bindings documentation, and I want to handle the empty case.
Previously, I could display a message when the items list is empty, but it’s not possible anymore with streams, since they don’t implement count or empty.
Is there a way to check when a stream is empty?
Trending in Questions
I’m working on a project that simulates the bumbl example in the programming phoenix book. It acts almost like an email client. We have a...
New
Hello,
I know there is an approach for handling lists that allows for optimized traversal, but I can’t recall the specific method (somet...
New
Hi everyone,
I am toying with the idea of building a “match maker” for giving personal help to people that wants to start coding.
I sta...
New
Documentation
While reading the Scoped Routes section, I noticed that the documentation currently refers to a problem without explainin...
New
So my question is quite simple and i have found no conclusive answer on forum, google or AI.
Should we use :erlang.float for Integer to ...
New
I recently noticed that Elixir’s Logger defaults its primary log level to :debug when no :logger, :level application configuration is pre...
New
apply_graft/2 doesn’t rewrite an add_many sub-workflow’s deps on an add step. Grafted jobs cancel with “upstream job was deleted”
Version...
New
Other Trending Topics
Hey, I’m Jesse and I’m the main contributor behind Dexter, a full-featured, lightning-fast Elixir LSP optimized for large codebases. It s...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Hi everyone!
The first release candidate for the Expert language server project is now available!
We’ve published a press release detai...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #metaprogramming
- #hex
- #security










Showing Posts 1 to 10- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
03juan
If you know factually that the data is empty on the server, perhaps set an
empty_data: trueassign that guards the empty message in the template?loics2
I thought about it, but I was wondering if there was a way to avoid implementing additional checks, only using the stream.
LostKobrakai
There’s not, because without additional constraints there’s no way to know the current state of the stream on the server as it is observed on the client.
chrismccord
if you have infinite scrolling, then you necessarily have pagination for next/previous page, no? Then you can toggle an empty state assign as other have alluded to when you hit no results without having to check the existing stream contents.
codeanpeace
Thinking out loud, this could be a good use case for the
:first-childor:last-childpseudoselectors. This will let the browser determine how to display the empty list message based on whether there are any other streamed elements rendered.I got an example working by adding the following line to the
.tablecore component as the first<tr>before the streamed ones. You could also add it to the end and use the:first-childpseudoselector instead.https://github.com/codeanpeace/live_cal/commit/cbdda424d6d352af9c240734c334207016651d4b
loics2
Yeah, you’re right, that shouldn’t be an issue, using something like the
end_of_timeline?assign in the docs.Oh nice idea! I tried to do something with the
:emptypseudoselector, but it’s sensible to whitespace which makes it hard to have something generic.belgoros
I have no pagination at all on my articles index template. I tried to apply your fix, but the message is displayed after deleting a single item and even if there is at least 1 item left.
sodapopcan
What does the code look like?
You would need something like this:
belgoros
Ah, no, I just modified the
core_components.ex, functiontable/1by adding a single line as you did in your GitHub repo:In my index template the code to display items looks like that:
I was redirected here from this thread
sodapopcan
I’m not @codeanpeace, I’m from that other thread and just butting in since we were talking there
The important bit to see is where you put it in the
tablecomponent. Is it possible you put it outside thetbodyor something or maybe have other modifications that would result in there being more thantrleft even when there are no articles? I would inspect the DOM after deleting the last one and ensure there is only onetrleft.