Skip to content
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

keep_live access callback result in subscribe #122

Open
xanderio opened this issue Dec 15, 2023 · 1 comment
Open

keep_live access callback result in subscribe #122

xanderio opened this issue Dec 15, 2023 · 1 comment
Labels
enhancement New feature or request

Comments

@xanderio
Copy link

Describe the bug

When setting up a keep_live it's currently impossible to access the callback result for setting up any subscriptions.

To Reproduce
A minimal set of resource definitions and calls that can reproduce the bug.

socket
|> keep_live(
  :merge_request,
  fn socket ->
    Nxy.Workspace.MergeRequest.get_by_id!(params["id"])
  end,
  subscribe: [
    "merge_request:updated:#{socket.assigns.merge_request.project_id}" # <-- unable to access the project_id here
  ]
)

Expected behavior

subscription should could be a callback that get's the result of the previous callback.

@xanderio xanderio added the bug Something isn't working label Dec 15, 2023
@zachdaniel zachdaniel added enhancement New feature or request and removed bug Something isn't working labels Dec 15, 2023
@zachdaniel
Copy link
Contributor

zachdaniel commented Dec 15, 2023

Makes sense to add this, but I won't have time to do it for quite some time. What we ought to do is call the callback on returned data, and store what we subscribed to. Then, as data updates, we should call the callback again and unsubscribe from any that are not present in the list, and subscribe to anything new. Would this be something you're interested in putting together a PR for? Happy to provide guidance if so.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants