From a7c4e5074328c50acf03ef0bf5bd44c31c80fed1 Mon Sep 17 00:00:00 2001 From: Frederik Wordenskjold Date: Mon, 21 Jul 2014 15:35:58 +0200 Subject: [PATCH] Added channel support to Marionette.d.ts Marionette.d.ts includes definitions for Backbone.Wreqr, but does not support the recommended way of using the Wreqr object as seen here: https://github.com/marionettejs/backbone.marionette/blob/master/docs/marionette.application.md#accessing-the-global-channel I've added the Channel object, and a definition to the Radio class as well. This is only a means of getting a specific channel through the channel() method, so while it is possible to create an instance of Radio, I've chosen only to include channel() method, and make it static. This makes it possible to access the instance of a channel with the name 'global' like this (created if not found), as recommended in the above documentation: var channel = Backbone.Wreqr.radio.channel('global'); // channel.vent; Finally, I've made the parameter context of the setHandler method in the Backbone.Wreqr.Handlers class optional, as this adheres to the actual implementation. --- marionette/marionette.d.ts | 24 +++++++++++++++++++++++- 1 file changed, 23 insertions(+), 1 deletion(-) diff --git a/marionette/marionette.d.ts b/marionette/marionette.d.ts index 96672ca3f4..9ff239dc52 100644 --- a/marionette/marionette.d.ts +++ b/marionette/marionette.d.ts @@ -57,13 +57,35 @@ declare module Backbone { // Backbone.Wreqr module Wreqr { + class radio { + + static channel(channelName: string): Channel; + + } + + class Channel { + + constructor(channelName: string); + + vent: Backbone.Wreqr.EventAggregator; + reqres: Backbone.Wreqr.RequestResponse; + commands: Backbone.Wreqr.Commands; + channelName: string; + + reset(): Channel; + connectEvents(hash: string, context: any): Channel; + connectCommands(hash: string, context: any): Channel; + connectRequests(hash: string, context: any): Channel; + + } + class Handlers extends Backbone.Events { constructor(options?: any); options: any; - setHandler(name: string, handler: any, context: any): void; + setHandler(name: string, handler: any, context?: any): void; hasHandler(name: string): boolean; getHandler(name: string): Function; removeHandler(name: string);