Last active
May 28, 2016 09:04
-
-
Save klikstermkd/418e52dbe29e043c74d09a452d5a822f to your computer and use it in GitHub Desktop.
JS Coding Challenge Solution - https://medium.com/@kitze/js-coding-challenge-1-test-your-skills-63c2af5446d0#.40xyjne8w
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const arr = [ | |
() => this.setState({moveCircleToMiddle: true}), | |
1000, | |
() => this.setState({showGrayCircle: true}), | |
() => this.setState({showMicrophone: true}), | |
500, | |
() => this.setState({moveCircleToTop: true}), | |
1000, | |
() => this.setState({pulseGrayCircle: true}), | |
500, | |
() => this.setState({okText: 1}), | |
500, | |
() => this.setState({okText: 2}), | |
500, | |
() => this.setState({googleText: 1}), | |
500, | |
() => this.setState({googleText: 2}) | |
]; | |
const delay = ms => new Promise(resolve => setTimeout(resolve, ms)); | |
async function sequence(...arr) { | |
for (const el of arr) { | |
typeof el === 'function' ? el() : await delay(el); | |
} | |
}; | |
sequence.apply(this, arr); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment