Over the past couple of weeks I’ve seen the same question asked a few times:
how do you go about resetting (restarting) a stream-enabled list of items in LiveView 0.18.x.
I’ll try to present it as a use case scenario.
A filtering input box lets one to filter a list of grocery items. Filtering should happen on-the-fly (phx-change
with debouncing.)
In the meantime availability of each item is coming externally and visually hints every user of a “5 only left” or “none left”, etc. in real time. So the items only disappear during filtering.
I’m seeing a huge benefit in implementing it as a stream. But I really struggle with a straightforward solution.
How would I reset the stream and start fresh after a filter update while maintaining focus and the cursor position inside the filter input box?