Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Does anyone have any ideas how to make promises look nicer in CoffeeScript?
registerNewUser: ->
@session.flush().then(((models)=>
newUser = @get('content')
@transitionToRoute('user', newUser)
), ((response)->
console.log response
))
@jimsynz

This comment has been minimized.

Copy link
Owner Author

@jimsynz jimsynz commented Aug 19, 2013

I'd prefer to see something along the lines of:

@session.flush
  then: (models)=>
    newUser = @get('content')
    @transitionToRoute('user', newUser)
  error: (response)->
    console.log response

but since I can't have that, I'm left with a whole shiteload of braces trying to delimit which function is which argument.

@passcod

This comment has been minimized.

Copy link

@passcod passcod commented Aug 19, 2013

You don't actually need the parens if you don't mind only having the comma to separate the functions (visually, it's less than optimal):

registerNewUser: ->
  @session.flush().then (models)=>
    newUser = @get('content')
    @transitionToRoute('user', newUser)
  , (response)->
    console.log response
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment