Skip to content

Add a function to temporarily disable callbacks #43

Open

Description

@specht

When I'm adding a lot of songs one by one (which as far as I can see can't be done any other way), the :playlist callback gets fired multiple times, which is correct. But it would be nice to be able to temporarily disable callbacks for potentially long operations, like this:

class MPD
  def no_callbacks(&block)
    # pause callback thread (or stop it)
    yield
    # resume callback thread (or restart it)
  end
end

mpd.no_callbacks do
  # add many songs here
end
# :playlist callback gets fired here

This way, my client would get the updated playlist when it's finished and wouldn't have to process multiple incomplete updates. At the end of the provided block, the callback thread would resume as usual and emit all changed keys. This requires that the callback cannot only be stopped, but also resumed (or stopped and then restarted).

Any feedback would be appreciated!

Activity

  1. mikerodrigues commented on Nov 3, 2015

    @mikerodrigues
    Contributor

    You can add songs based on a search and it will only emit one :playlist event:

    mpd.where({artist: 'MyArtiSt'}, {add: true})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions