David

Joined

42,960 Experience
422 Lessons Completed
1 Question Solved

Activity

Posted in Responsive Navigation with Turbo Discussion

One problem is if you are using this and you go to a show view; the request.path would now include the ID of the record you are looking at. While you are not at the index view that the navigation points to anymore, the dropdown will default to the first element again. So it might be a good idea to use include_blank: true or a prompt: "Navigation" to avoid issues trying to access that first navigation option.

Ultimately I setup the button-press that would queue the background job to send a turbo_stream response to append a loading partial

<%= turbo_stream.append "loading", partial: "shared/loading" %>

and at the end of the background job it broadcasts a removal:

# current_user is passed to the background job in part so we can broadcast the remove to the right user
Turbo::StreamsChannel.broadcast_remove_to("loading:#{user.id}", target: "loading_message")

So I have a long-running API call running in a background job. As records are created/updated/removed in that job I have them broadcasted to the user. I would like to have a notification/badge added when the background job is started and have it removed when the job finishes (so the user doesn't think something is broken because not all their data is showing up).

I have experimented with a few ideas, but none of them worked or felt quite right (e.g. having a "loading" boolean field on the user and triggering broadcasts for when that specific field changed value).