Skip to content

Instantly share code, notes, and snippets.

@trezy
Last active August 29, 2015 14:07
Show Gist options
  • Save trezy/106817dd13a371a4da7b to your computer and use it in GitHub Desktop.
Save trezy/106817dd13a371a4da7b to your computer and use it in GitHub Desktop.
A shim to replace Backbone.Wreqr with Backbone.Radio in Marionette. Requires Marionette v2.1+ (Coffeescript)
# Based on https://gist.github.com/jmeas/7992474cdb1c5672d88b
radioShim = ( root, factory ) ->
if typeof define is 'function' and define.amd
define [
'backbone.marionette'
'backbone.radio'
'underscore'
], ( Marionette, Radio, _ ) ->
factory Marionette, Radio, _
else if typeof exports?
Marionette = require 'backbone.marionette'
Radio = require 'backbone.radio'
_ = require 'underscore'
module.exports = factory Marionette, Radio, _
else
factory root.Backbone.Marionette, root.Backbone.Radio, root._
radioShim window, ( Marionette, Radio, _ ) ->
Marionette.Application.prototype._initChannel = ->
@channelName = _.result( @, 'channelName' ) or 'global'
@channel = _.result( @, 'channel' ) or Radio.channel @channelName
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment