-
Notifications
You must be signed in to change notification settings - Fork 934
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add assign_async and start_async #2763
Conversation
lib/phoenix_live_view.ex
Outdated
cancel_existing_async(socket, :preview) | ||
cancel_existing_async(socket, socket.assigns.preview) | ||
""" | ||
def cancel_existing_async(socket, async_or_keys, reason \\ :cancel) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same about the default reason here.
lib/phoenix_live_view/async.ex
Outdated
end | ||
end | ||
|
||
def cancel_async(%Socket{} = socket, key, _reason) do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't we support a list of keys? I don't see where that is handled. :( But also note that if I do:
cancel_async(socket, :key, ...)
We won't set the async_result under socket.assign.key to failed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the "key" is whatever the user passes to start_async
, so :foo
or [:foo, :bar, :baz]
. So the list of keys is supported because the key is a list of keys in some cases. I will bump the docs around this.
Co-authored-by: José Valim <[email protected]>
Co-authored-by: José Valim <[email protected]>
Co-authored-by: José Valim <[email protected]>
Co-authored-by: José Valim <[email protected]>
Co-authored-by: José Valim <[email protected]>
Love to see support for this in LiveView. ❤️ Just a thought (sorry if this should be shared elsewhere): While messing with asynchronous assignments in the past, I occasionally found it helpful to perform atomic updates (via |
Still a WIP but ready for initial review to help finalize some things