Skip to content

Using backcalls with Promises #754

@mayeaux

Description

@mayeaux

I have some code that runs a Promise on repeat.

putOnRotation = (callback, delay) ->
  return callback delay
  .then (data) ->
    console.log(data)
    return Promise.delay(delay).then ->
      return putOnRotation callback, delay
  .catch (error) ->
    console.log(error)
    return Promise.delay(5000).then ->
      return putOnRotation callback, delay

However, I don't like this pyramid pattern, and would prefer to use backcalls.

I've ran into a litany of issues getting them set up, any ideas on how I could remove the indentation of this function using backcalls? Thanks.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions