Skip to content

added new render to method - #739

Open
igorkasyanchuk wants to merge 2 commits into
hotwired:mainfrom
igorkasyanchuk:add_turbo_stream_later_to
Open

added new render to method#739
igorkasyanchuk wants to merge 2 commits into
hotwired:mainfrom
igorkasyanchuk:add_turbo_stream_later_to

Conversation

@igorkasyanchuk

Copy link
Copy Markdown
Contributor

I think we are missing an easy way to render stream actions in background.

I want to have code like this:

    def update_unread_conversations_count(user)
      conversations_count = user.available_conversations.unread_for_user(user).count
      # conversations_count = rand(3)
      actions = [
        turbo_stream_action_tag(:update, template: conversations_count, target: "unread-conversations-count-sidebar"),
        if conversations_count > 0
          turbo_stream_action_tag(:remove_css_class, target: "unread-conversations-count-sidebar", classes: "hidden")
        else
          turbo_stream_action_tag(:add_css_class, target: "unread-conversations-count-sidebar", classes: "hidden")
        end
      ]
      broadcast_stream_later_to([user, :updates], content: actions.join("\n"))
    end

@igorkasyanchuk

Copy link
Copy Markdown
Contributor Author

I don't understand how to fix failed CI builds. Not related to my code changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant