Skip to content

Latest commit

 

History

History
36 lines (28 loc) · 439 Bytes

dispatching-promises.md

File metadata and controls

36 lines (28 loc) · 439 Bytes

Dispatching Promises

Implicitly

const foo = () => ({
  type: 'FOO',
  payload: new Promise()
});

Explicitly

const foo = () => ({
  type: 'FOO',
  payload: {
    promise: new Promise()
  }
});

Async/Await

For more on using async/await, see the guide.

const foo = () => ({
  type: 'FOO',
  async payload() {
    const data = await getDataFromApi():

    return data;
  }
});