提交 a67fdc02 编写于 作者: G Guo Xiang Tan

Update documentation to reflect unsubscription with name.

上级 02ee081c
......@@ -141,6 +141,11 @@ module ActiveSupport
#
# ActiveSupport::Notifications.unsubscribe(subscriber)
#
# You can also unsubscribe by passing the name of the subscriber object. Note
# that this will unsubscribe all subscriptions with the given name:
#
# ActiveSupport::Notifications.unsubscribe("render")
#
# == Default Queue
#
# Notifications ships with a queue implementation that consumes and publishes events
......@@ -173,8 +178,8 @@ def subscribed(callback, *args, &block)
unsubscribe(subscriber)
end
def unsubscribe(args)
notifier.unsubscribe(args)
def unsubscribe(subscriber_or_name)
notifier.unsubscribe(subscriber_or_name)
end
def instrumenter
......
......@@ -25,9 +25,9 @@ def subscribe(pattern = nil, block = Proc.new)
subscriber
end
def unsubscribe(subscriber)
def unsubscribe(subscriber_or_name)
synchronize do
@subscribers.reject! { |s| s.matches?(subscriber) }
@subscribers.reject! { |s| s.matches?(subscriber_or_name) }
@listeners_for.clear
end
end
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册