@@ -233,6 +233,19 @@ Radio.Commands = {
233
233
}
234
234
} ;
235
235
236
+ // listenTo equivalent for Commands
237
+ var listenMethods = { complyFor : 'comply' , complyForOnce : 'complyOnce' } ;
238
+ _ . each ( listenMethods , function ( implementation , method ) {
239
+ Radio . Commands [ method ] = function ( obj , name , callback ) {
240
+ var listeningTo = this . _listeningTo || ( this . _listeningTo = { } ) ;
241
+ var id = obj . _listenId || ( obj . _listenId = _ . uniqueId ( 'c' ) ) ;
242
+ listeningTo [ id ] = obj ;
243
+ if ( ! callback && typeof name === 'object' ) { callback = this ; }
244
+ obj [ implementation ] ( name , callback , this ) ;
245
+ return this ;
246
+ } ;
247
+ } ) ;
248
+
236
249
//
237
250
// Backbone.Radio.Requests
238
251
// A messaging system for requesting data.
@@ -322,6 +335,19 @@ Radio.Requests = {
322
335
}
323
336
} ;
324
337
338
+ // listenTo equivalent for Requests
339
+ var listenMethods = { replyFor : 'reply' , replyForOnce : 'replyOnce' } ;
340
+ _ . each ( listenMethods , function ( implementation , method ) {
341
+ Radio . Requests [ method ] = function ( obj , name , callback ) {
342
+ var listeningTo = this . _listeningTo || ( this . _listeningTo = { } ) ;
343
+ var id = obj . _listenId || ( obj . _listenId = _ . uniqueId ( 'r' ) ) ;
344
+ listeningTo [ id ] = obj ;
345
+ if ( ! callback && typeof name === 'object' ) { callback = this ; }
346
+ obj [ implementation ] ( name , callback , this ) ;
347
+ return this ;
348
+ } ;
349
+ } ) ;
350
+
325
351
//
326
352
// Backbone.Radio.channel
327
353
// Get a reference to a channel by name.
0 commit comments