-
Notifications
You must be signed in to change notification settings - Fork 149
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
alias global and temporary listener methods to "subscribe" for consistancy #72
Conversation
also documentation needs to be updated to indicate that Wisper.add_listener(MyListener.new, scope: :MyPublisher)
Wisper.add_listener(MyOtherListener.new, scope: :MyPublisher) can be used as Wisper.subscribe(MyListener.new, MyOtherListener.new, scope: :MyPublisher) |
Thanks for this. I've had a quick look and my first thoughts are it looks pretty complete. I wouldn't insist on DRYing the specs, I think its probably okay as it is (open to suggestion). I think the specs could be named better. I don't think you need to mention it '.subscribe (given block) subscribes listeners to all events for duration of the block'
it '.subscribe subscribes listeners to all events' For the README I'd be tempted to remove the def self.subscribe(*args, &block)
if block_given?
TemporaryListeners.with(*args, &block)
else
options = args.last.is_a?(Hash) ? args.pop : {}
args.each do |listener|
GlobalListeners.add(listener, options)
end
end
end If we did this we could also remove the specs for What do you think? The CHANGELOG also need updating with this new feature. |
I've added deprecation warning for I've kept the tests of both I've better formatted the I've also better formatted the specs for the also If you like to remove the |
about removing the specs for Merging this now, closes #66 |
Had a real quick look over this, nice work, I like how the specs read 👍 I think I'd like to Sound reasonable? Quick tip: for commits which only change docs you can add |
Done 😄, and thanks for the help... I've made DEPRECATION testing in a separate commit (e294fa6) so it's easy to revert it if you don't like the change |
Excellent, thanks for your contribution. I'm happy with the deprecation spec workaround. One last thing please, can you squash all the commits into one commit (and force push), then I will merge ready for the release to Rubygems next week. The commit message should be something like "add Wisper#subscribe method which replaces both |
which replaces both .with_listeners and .add_listener
Done 😄 |
alias global and temporary listener methods to "subscribe" for consistancy
Many thanks 😄 |
responding to issue #66
Please note that I'm not that experienced with the gem, so I added a this PR draft to discuss and complete the issue.
I also suspect that the testing I've done is not sufficient.
and I'm sure that the testing is not DRY... maybe moving the specs of all the 3 methods (
.subscribe
,.with_listeners
,.add_listener
) to a shared examples be better -which I plan to do before merging-