Index: base/ios/crb_protocol_observers.h |
diff --git a/base/ios/crb_protocol_observers.h b/base/ios/crb_protocol_observers.h |
index 15d16569ff84660365dceaf4088e2b8c9ecfda34..560f0dcbfb39c3d2845f0bd370983f8f32690c4d 100644 |
--- a/base/ios/crb_protocol_observers.h |
+++ b/base/ios/crb_protocol_observers.h |
@@ -13,6 +13,10 @@ typedef void (^ExecutionWithObserverBlock)(id); |
// protocol. The container forwards method invocations to its contained |
// observers, so that sending a message to all the observers is as simple as |
// sending the message to the container. |
+// It is safe for an observer to remove itself or another observer while being |
+// notified. It is also safe to add an other observer while being notified but |
+// the newly added observer will not be notified as part of the current |
+// notification dispatch. |
droger
2015/06/04 10:04:23
Optional, but would be nice:
add a code example (s
jbbegue
2015/06/04 12:13:02
Acknowledged.
|
@interface CRBProtocolObservers : NSObject |
// The Objective-C protocol that the observers in this container conform to. |
@@ -20,7 +24,7 @@ typedef void (^ExecutionWithObserverBlock)(id); |
// Returns a CRBProtocolObservers container for observers that conform to |
// |protocol|. |
-+ (CRBProtocolObservers*)observersWithProtocol:(Protocol*)protocol; |
++ (instancetype)observersWithProtocol:(Protocol*)protocol; |
// Adds |observer| to this container. |
- (void)addObserver:(id)observer; |
@@ -28,6 +32,9 @@ typedef void (^ExecutionWithObserverBlock)(id); |
// Remove |observer| from this container. |
- (void)removeObserver:(id)observer; |
+// Returns true if there is currently no observers. |
+- (BOOL)empty; |
+ |
// Executes callback on every observer. |callback| cannot be nil. |
- (void)executeOnObservers:(ExecutionWithObserverBlock)callback; |