Custom event data argument is 'undefined'

I’m trying to use custom event publishing using and  The basic event system is working, but I’m having problems getting the data argument to work.  If I publish with:'my.custom.event', 'my argument')

I get an error during the publishing:

Uncaught TypeError: Function.prototype.apply: Arguments list has wrong type

If instead I publish using a generic object for the data parameter, such as:'my.custom.event', {myarg: 'my argument'})

the publish works fine, and the subscribe handler gets called.  However, the data argument passed to the handler is ‘undefined’ rather than containing my custom object.  My handler looks something like this:'my.custom.event', function(data) { console.log(data); });

Any hints on what I might be doing wrong?


- Chris


Sorry this isn’t documented, we’ll add this, but you need to pass an array, like this:‘my.custom.event’, [‘my argument 1’,‘my argument 2’]);

Each Item in the Array will be converted into an argument handed to the subscriber function. We recommend just having one argument, and having it be a JavaScript object with as many properties as you need, but this is up to you.

For instance:

var eventParams = {<br>&nbsp; &nbsp;foo: 'bar',<br>&nbsp; &nbsp;name: 'Zach'<br>};<br>'my.custom.event', [eventParams, 'Mint Chocolate Chip']);

Then your subscriber function should do this:'my.custom.event',function(eventParams, favoriteIceCream){<br>&nbsp; &nbsp; console.log('Foo: ' +;<br>&nbsp; &nbsp; console.log('Name: ' +;<br>&nbsp; &nbsp; console.log('Favorite Ice Cream: ' + favoriteIceCream);<br>});

Phew - I was worried it was me!  Thanks for the writeup… I’ll give it a go.

- Chris

Just wanted to confirm that this method works great.  Thanks!

I have updated the API documentation to clarify the expected data arguments.