Skip to content

Commit

Permalink
Added helper and task files
Browse files Browse the repository at this point in the history
  • Loading branch information
Samrith Shankar committed Dec 3, 2018
1 parent 9ed0647 commit 5ccfdc4
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
19 changes: 19 additions & 0 deletions demo/src/examples/util/helper.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
export const getElements = id => {
const element = document.getElementById('example-1');
const button = element.querySelector('.btn');
const console = element.querySelector('.console');
const start = console.querySelector('.console__on-start');
const done = console.querySelector('.console__on-done');
const end = console.querySelector('.console__on-end');

return {
element,
console: {
console,
start,
done,
end
},
button
};
};
17 changes: 17 additions & 0 deletions demo/src/examples/util/task.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
export const queueTasks = (instance, count, { onStart, onDone, onEnd }) => {
const orderOfCompletion = [];
for (let i = 0; i < count; i++) {
instance.add(task(i + 1, orderOfCompletion));
}
instance.onStart = onStart;
instance.onDone = onDone;
instance.onEnd = onEnd;
};

export const task = (number, orderOfCompletion = []) => done => {
const timeout = Math.random() * 1000;
setTimeout(() => {
done();
orderOfCompletion.push(number);
}, timeout);
};

0 comments on commit 5ccfdc4

Please sign in to comment.