David
David

Reputation: 36354

How to write this function in coffeescript

I am struggling to re-produce a function like this in coffeescript could someone help me out a little.

// Listen to message from child window
 eventer(messageEvent,function(e) {
     console.log('parent received message!:  ',e.data);
 },false);

Upvotes: 0

Views: 89

Answers (2)

Justin Morgan
Justin Morgan

Reputation: 30660

# Listen to message from child window
eventer messageEvent, (e) ->
     console.log "parent received message!:  #{e.data}"
, false

Verified with coffeescript.org's sandbox CoffeeScript compiler.

Upvotes: 0

dcro
dcro

Reputation: 13649

Your code translates to this equivalent one in CoffeeScript:

# Listen to message from child window
eventer messageEvent, ((e) ->
  console.log "parent received message!:  ", e.data
), false

You can always use this tool in the future if you need help with the CoffeeScript equivalence of a JavaScript code:

http://js2coffee.org/

Upvotes: 2

Related Questions