Skip to content

Instantly share code, notes, and snippets.

@weslleyaraujo
Created December 21, 2016 17:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save weslleyaraujo/0265e7fb4389afab4d145451c8870a89 to your computer and use it in GitHub Desktop.
Save weslleyaraujo/0265e7fb4389afab4d145451c8870a89 to your computer and use it in GitHub Desktop.
import sleep from 'utils/sleep';
const SONG_DELAY_TIME = 400;
export const sing = payload => async (dispatch, getState) => {
dispatch(startSong());
const { match } = getState();
for (let i = 0; i <= match.all.length - 1; i++) {
const id = match.all[i];
dispatch(lightenPad({ id }));
await sleep(SONG_DELAY_TIME); // sleep time during note play
dispatch(lightenOffPad());
await sleep(SONG_DELAY_TIME); // sleep time before next note
}
dispatch(finishSong());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment