@@ -22,11 +22,21 @@ export default class Delegator {
2222 }
2323 }
2424
25+ /**
26+ * @ngdoc method
27+ * @module knalli.angular-vertxbus
28+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
29+ * @name .#registerHandler
30+ *
31+ * @description
32+ * Registers a callback handler for the specified address match.
33+ *
34+ * @param {string } address target address
35+ * @param {object } headers optional headers
36+ * @param {function } callback handler with params `(message, replyTo)`
37+ * @returns {function } deconstructor
38+ */
2539 registerHandler ( address , headers , callback ) {
26- if ( angular . isFunction ( headers ) && ! callback ) {
27- callback = headers ;
28- headers = undefined ;
29- }
3040 if ( ! this . handlers [ address ] ) {
3141 this . handlers [ address ] = [ ] ;
3242 }
@@ -57,26 +67,47 @@ export default class Delegator {
5767 deconstructor . displayName = `${ moduleName } .service.registerHandler.deconstructor` ;
5868 return deconstructor ;
5969 }
70+
71+ /**
72+ * @ngdoc method
73+ * @module knalli.angular-vertxbus
74+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
75+ * @name .#on
76+ *
77+ * @description
78+ * See (using {@link knalli.angular-vertxbus.vertxEventBusService#methods_registerHandler registerHandler()})
79+ */
6080 on ( address , headers , callback ) {
61- if ( typeof headers === 'function' && ! callback ) {
62- callback = headers ;
63- headers = undefined ;
64- }
6581 return this . registerHandler ( address , headers , callback ) ;
6682 }
83+
84+ /**
85+ * @ngdoc method
86+ * @module knalli.angular-vertxbus
87+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
88+ * @name .#addListener
89+ *
90+ * @description
91+ * See (using {@link knalli.angular-vertxbus.vertxEventBusService#methods_registerHandler registerHandler()})
92+ */
6793 addListener ( address , headers , callback ) {
68- if ( typeof headers === 'function' && ! callback ) {
69- callback = headers ;
70- headers = undefined ;
71- }
7294 return this . registerHandler ( address , headers , callback ) ;
7395 }
7496
97+ /**
98+ * @ngdoc method
99+ * @module knalli.angular-vertxbus
100+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
101+ * @name .#unregisterHandler
102+ *
103+ * @description
104+ * Removes a callback handler for the specified address match.
105+ *
106+ * @param {string } address target address
107+ * @param {object } headers optional headers
108+ * @param {function } callback handler with params `(message, replyTo)`
109+ */
75110 unregisterHandler ( address , headers , callback ) {
76- if ( typeof headers === 'function' && ! callback ) {
77- callback = headers ;
78- headers = undefined ;
79- }
80111 // Remove from internal map
81112 if ( this . handlers [ address ] ) {
82113 var index = this . handlers [ address ] . indexOf ( { headers, callback} ) ;
@@ -92,58 +123,190 @@ export default class Delegator {
92123 this . delegate . unregisterHandler ( address , headers , callback ) ;
93124 }
94125 }
126+
127+ /**
128+ * @ngdoc method
129+ * @module knalli.angular-vertxbus
130+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
131+ * @name .#un
132+ *
133+ * @description
134+ * See (using {@link knalli.angular-vertxbus.vertxEventBusService#methods_registerHandler unregisterHandler()})
135+ */
95136 un ( address , headers , callback ) {
96- if ( typeof headers === 'function' && ! callback ) {
97- callback = headers ;
98- headers = undefined ;
99- }
100137 return this . unregisterHandler ( address , headers , callback ) ;
101138 }
139+
140+ /**
141+ * @ngdoc method
142+ * @module knalli.angular-vertxbus
143+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
144+ * @name .#removeListener
145+ *
146+ * @description
147+ * See (using {@link knalli.angular-vertxbus.vertxEventBusService#methods_registerHandler unregisterHandler()})
148+ */
102149 removeListener ( address , headers , callback ) {
103- if ( typeof headers === 'function' && ! callback ) {
104- callback = headers ;
105- headers = undefined ;
106- }
107150 return this . unregisterHandler ( address , headers , callback ) ;
108151 }
109152
110- send ( address , message , options = { } ) {
111-
112- // FALLBACK: signature change since 2.0
113- if ( ! angular . isObject ( options ) ) {
114- this . $log . error ( `${ moduleName } : Signature of vertxEventBusService.send() has been changed!` ) ;
115- return this . send ( address , message , {
116- timeout : arguments [ 2 ] !== undefined ? arguments [ 2 ] : 10000 ,
117- expectReply : arguments [ 3 ] !== undefined ? arguments [ 3 ] : true
118- } ) ;
119- }
120-
121- return this . delegate . send ( address , message , options . timeout , options . expectReply ) ;
153+ /**
154+ * @ngdoc method
155+ * @module knalli.angular-vertxbus
156+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
157+ * @name .#send
158+ *
159+ * @description
160+ * Sends a message to the specified address (using {@link knalli.angular-vertxbus.vertxEventBus#methods_send vertxEventBus.send()}).
161+ *
162+ * @param {string } address target address
163+ * @param {object } message payload message
164+ * @param {object } headers headers
165+ * @param {number= } [options.timeout=10000] (in ms) after which the promise will be rejected
166+ * @param {boolean= } [options.expectReply=true] if false, the promise will be resolved directly and
167+ * no replyHandler will be created
168+ * @returns {object } promise
169+ */
170+ send ( address , message , headers = { } , options = { timeout : 10000 , expectReply : true } ) {
171+ return this . delegate . send ( address , message , headers , options . timeout , options . expectReply ) ;
122172 }
123173
124- publish ( address , message ) {
125- return this . delegate . publish ( address , message ) ;
174+ /**
175+ * @ngdoc method
176+ * @module knalli.angular-vertxbus
177+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
178+ * @name .#publish
179+ *
180+ * @description
181+ * Publishes a message to the specified address (using {@link knalli.angular-vertxbus.vertxEventBus#methods_publish vertxEventBus.publish()}).
182+ *
183+ * @param {string } address target address
184+ * @param {object } message payload message
185+ * @param {object= } headers headers
186+ * @returns {boolean } false if cannot be send or queued
187+ */
188+ publish ( address , message , headers = { } ) {
189+ return this . delegate . publish ( address , message , headers ) ;
126190 }
127- emit ( address , message ) {
128- return this . publish ( address , message ) ;
191+
192+ /**
193+ * @ngdoc method
194+ * @module knalli.angular-vertxbus
195+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
196+ * @name .#emit
197+ *
198+ * @description
199+ * See (using {@link knalli.angular-vertxbus.vertxEventBusService#methods_publish publish()})
200+ */
201+ emit ( address , message , headers = { } ) {
202+ return this . publish ( address , message , headers ) ;
129203 }
130204
205+ /**
206+ * @ngdoc method
207+ * @module knalli.angular-vertxbus
208+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
209+ * @name .#getConnectionState
210+ *
211+ * @description
212+ * Returns the current connection state. The state is being cached internally.
213+ *
214+ * @returns {number } state type of vertx.EventBus
215+ */
131216 getConnectionState ( ) {
132217 return this . delegate . getConnectionState ( ) ;
133218 }
134219
220+ /**
221+ * @ngdoc method
222+ * @module knalli.angular-vertxbus
223+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
224+ * @name .#readyState
225+ *
226+ * @description
227+ * See (using {@link knalli.angular-vertxbus.vertxEventBusService#methods_getConnectionState getConnectionState()})
228+ */
135229 readyState ( ) {
136230 return this . getConnectionState ( ) ;
137231 }
138232
233+
234+
235+ /**
236+ * @ngdoc method
237+ * @module knalli.angular-vertxbus
238+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
239+ * @name .#isConnectionOpen
240+ *
241+ * @description
242+ * Returns true if the current connection state ({@link knalli.angular-vertxbus.vertxEventBusService#methods_getConnectionState getConnectionState()}) is `OPEN`.
243+ *
244+ * @returns {boolean } connection open state
245+ */
246+ isConnectionOpen ( ) {
247+ return this . isConnectionOpen ( ) ;
248+ }
249+
250+ /**
251+ * @ngdoc method
252+ * @module knalli.angular-vertxbus
253+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
254+ * @name .#isEnabled
255+ *
256+ * @description
257+ * Returns true if service is being enabled.
258+ *
259+ * @returns {boolean } state
260+ */
139261 isEnabled ( ) {
140262 return this . delegate . isEnabled ( ) ;
141263 }
142264
265+ /**
266+ * @ngdoc method
267+ * @module knalli.angular-vertxbus
268+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
269+ * @name .#isConnected
270+ *
271+ * @description
272+ * Returns true if service (and the eventbus) is being connected.
273+ *
274+ * @returns {boolean } state
275+ */
143276 isConnected ( ) {
144277 return this . delegate . isConnected ( ) ;
145278 }
146279
280+ /**
281+ * @ngdoc method
282+ * @module knalli.angular-vertxbus
283+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
284+ * @name .#isValidSession
285+ *
286+ * @description
287+ * Returns true if the session is valid
288+ *
289+ * @returns {boolean } state
290+ */
291+ isValidSession ( ) {
292+ return this . delegate . isValidSession ( ) ;
293+ }
294+
295+ /**
296+ * @ngdoc method
297+ * @module knalli.angular-vertxbus
298+ * @methodOf knalli.angular-vertxbus.vertxEventBusService
299+ * @name .#getMessageQueueLength
300+ *
301+ * @description
302+ * Returns the current amount of messages in the internal buffer.
303+ *
304+ * @returns {number } amount
305+ */
306+ getMessageQueueLength ( ) {
307+ return this . delegate . getMessageQueueLength ( ) ;
308+ }
309+
147310 login ( username , password , timeout ) {
148311 return this . delegate . login ( username , password , timeout ) ;
149312 }
0 commit comments