Dispatching sequence


#1

I want to dispatch 2 events in sequence order.
For now, i found only this way:

atom.commands.add 'atom-text-editor', 'custom:sort-beauty', ->
  editorElement = atom.views.getView(atom.workspace.getActiveTextEditor())
  atom.commands.selectorBasedListenersByCommandName["postcss-sorting:run"][0].callback()
    .then(()=> atom.commands.dispatch(editorElement, 'atom-beautify:beautify-editor'))

but maybe i need another way?