Livescript, How to end a unnested callback?

Livescript, How to end a unnested callback?

Problem

Reffering to: http://livescript.net Unnested callbacks and parentheses free chaining: LiveScript

<-! $ 'h1' .on 'click'
alert 'boom!'

JavaScript

$('h1').on('click', function(){
  alert('boom!');
});

How can I write livescript like this in Javascript?

JavaScript

$('h1').on('click', function(){
  alert('boom!');
});
alert('out of callback');
Problem courtesy of: Lhfcws

Solution

You can’t. That’s backcall.

You have two options : use a do (I don’t think it makes sense)

do
  <- $ 'h1' .on 'click'
  alert 'boom!'

… Or just use a callback ?!

$ 'h1' .on 'click' ->
  alert 'boom'
Solution courtesy of: Ven

Discussion

Leave a Reply

Your email address will not be published. Required fields are marked *