Keyset pagination-backed `Api.stream!/2` is now available in `main`
zachdaniel
2023-04-26
zachdaniel:
It returns an Elixir Stream, and requires that the action you use it with has keyset pagination enabled. The primary use case is handling the results of a query when there may be so many that you don’t just want to collect them into a list. For example:
Resource
|> Ash.Query.for_read(:read)
|> Ash.Query.filter(foo == :bar)
|> Api.stream!()
|> Stream.map(&start_oban_job/1)
|> Stream.run()
I haven’t tried it yet, but this should also allow for a pattern around streams in liveview where you call
Api.stream
in a task, and insert into the liveview stream as the results come in.
bananoid00:
does AshPhoenix.LiveView.keep_live support streams?
zachdaniel:
no, not currently