efacilitation/eventric

Promises everywhere

Closed this issue · 0 comments

As a developer
I want to use promise resolve() and reject() instead of callbacks
So I can escape the callback hell


Currently several places have callback handlers which one needs to call to complete certain actions, as e.g. in CommandHandlers like that:

exampleContext.addCommandHandler 'DoSomething', (params, callback) ->
  # do something

  # success
  callback null, 'whatever'

  # error
  callback 'error', null

Instead we want to use a Promise here

exampleContext.addCommandHandler 'DoSomething', (params, promise) ->
  # do something

  # success
  promise.resolve 'whatever'

  # error
  promise.reject 'error'

EVENTRIC-39