@@ -54,8 +54,9 @@ - (void)dealloc
54
54
55
55
/* *
56
56
* The activate method is the point at which the module gets plugged into the xmpp stream.
57
- * Subclasses may override this method to perform any custom actions,
58
- * but must invoke [super activate:aXmppStream] at some point within their implementation.
57
+ *
58
+ * It is recommended that subclasses override didActivate, instead of this method,
59
+ * to perform any custom actions upon activation.
59
60
**/
60
61
- (BOOL )activate : (XMPPStream *)aXmppStream
61
62
{
@@ -73,6 +74,8 @@ - (BOOL)activate:(XMPPStream *)aXmppStream
73
74
74
75
[xmppStream addDelegate: self delegateQueue: moduleQueue];
75
76
[xmppStream registerModule: self ];
77
+
78
+ [self didActivate ];
76
79
}
77
80
};
78
81
@@ -84,13 +87,28 @@ - (BOOL)activate:(XMPPStream *)aXmppStream
84
87
return result;
85
88
}
86
89
90
+ /* *
91
+ * It is recommended that subclasses override this method (instead of activate:)
92
+ * to perform tasks after the module has been activated.
93
+ *
94
+ * This method is only invoked if the module is successfully activated.
95
+ * This method is always invoked on the moduleQueue.
96
+ **/
97
+ - (void )didActivate
98
+ {
99
+ // Override me to do custom work after the module is activated
100
+ }
101
+
87
102
/* *
88
103
* The deactivate method unplugs a module from the xmpp stream.
89
104
* When this method returns, no further delegate methods on this module will be dispatched.
90
105
* However, there may be delegate methods that have already been dispatched.
91
106
* If this is the case, the module will be properly retained until the delegate methods have completed.
92
107
* If your custom module requires that delegate methods are not run after the deactivate method has been run,
93
108
* then simply check the xmppStream variable in your delegate methods.
109
+ *
110
+ * It is recommended that subclasses override didDeactivate, instead of this method,
111
+ * to perform any custom actions upon deactivation.
94
112
**/
95
113
- (void )deactivate
96
114
{
@@ -102,6 +120,8 @@ - (void)deactivate
102
120
[xmppStream unregisterModule: self ];
103
121
104
122
xmppStream = nil ;
123
+
124
+ [self didDeactivate ];
105
125
}
106
126
};
107
127
@@ -111,6 +131,18 @@ - (void)deactivate
111
131
dispatch_sync (moduleQueue, block);
112
132
}
113
133
134
+ /* *
135
+ * It is recommended that subclasses override this method (instead of deactivate:)
136
+ * to perform tasks after the module has been deactivated.
137
+ *
138
+ * This method is only invoked if the module is transitioned from activated to deactivated.
139
+ * This method is always invoked on the moduleQueue.
140
+ **/
141
+ - (void )didDeactivate
142
+ {
143
+ // Override me to do custom work after the module is deactivated
144
+ }
145
+
114
146
- (dispatch_queue_t )moduleQueue
115
147
{
116
148
return moduleQueue;
0 commit comments