-
Notifications
You must be signed in to change notification settings - Fork 0
/
experimental.js
78 lines (78 loc) · 2.5 KB
/
experimental.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
// Should it be cycle or do (or omit entirely)
every(5).seconds.cycle([draw1, draw2, draw3]);
every(5).seconds.do(draw1);
// Every other - is this useful
every(2).other().minutes.do(draw1);
// Respond to events - is this part of the remit
every().mousePress.do(draw1);
every(4).other().mousePress(draw1);
// .cycle doesn't handle different length scenes
every(5).seconds.show(draw1, 5).show(draw2, 6).show(draw3, 5);
// what if different scenes have different interactions?
every(5)
.seconds.show(draw1, 5, scene1MousePress, scene1Keypress)
.show(draw2, 6)
.show(draw3, 5);
// what if a scene should play until some condition is met?
every(5)
.seconds.show(draw1, () => scene1Done)
.show(draw2)
.show(draw3);
// or maybe scenes can return completions
every(5).seconds.showUntilDone(draw1).show(draw2);
draw1 = () => 'done';
// What if a scene should just wait after a delay?
every(5)
.seconds.showUntil(draw1, () => scene1Done)
.show(draw2);
draw1 = () => {
setTimeout(() => (scene1Done = true), 5000);
};
// or promise style?
every(5).seconds.showUntil(draw1).show(draw2);
draw1 = (resolve) => {
setTimeout(resolve, 5000);
};
// or promise style with less presupposed knowledge on promises?
every(5).seconds.showUntil(draw1).show(draw2);
draw1 = (reportDone) => {
reportDone(5000);
};
// Should you be able to insert scenes?
timeline = every(5).seconds.show(draw1).show(draw2);
timeline.show(draw3);
timeline.Nth(2).show(draw4); // inserts draw4 after draw2
// Should scenes pass data to each other?
every(5).seconds.showUntil(draw1).show(draw2);
draw1 = (resolve) => {
resolve('foo');
};
draw2 = (resolve, lastSceneData) => {
console.log(lastSceneData);
};
// or maybe this should just be handled with global variables
// Maybe, you'll insert a scene, and later want to turn it off? or maybe insteaad
// of inserting/deleting you just need to toggle on/off?
every(5).seconds.show(draw1).show(draw2).if(checkDraw2Visible);
function checkDraw2Visible() {
return draw2Visible;
}
// What about running through a sequence of prerecorded events i.e. symphonyinacid.net
every(midiEvent).timestamp.react(processMidiEvent);
every(recordedEvents).timestamp.react(processRecordedEvent);
const recordedEvents = {0: [1], 5000: [2], 10000: [3]};
const processRecordedEvent = (event) => {
switch (event) {
case 1:
draw1();
break;
case 2:
draw2();
break;
case 3:
draw3();
break;
}
};
// or maybe avoiding the switch
every(recordedEvents).timestamp.react(1, draw1).react(2, draw2).react(3, draw3);