Skip to content

Commit bc3493e

Browse files
committed
commit
1 parent 4e825a7 commit bc3493e

File tree

5 files changed

+52
-46
lines changed

5 files changed

+52
-46
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "timeengine",
3-
"version": "5.0.3",
3+
"version": "5.1.0",
44
"description": "TimeEngine is a tiny, simple yet versatile JavaScript library of event system. Built for Declarative and Functional Reactive Programming.",
55
"main": "timeengine.js",
66
"scripts": {

react-test/index.jsx

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,23 @@
4040
const THETA = DEG / 180 * Math.PI; //radian
4141
const G = 9.8; //gravity const
4242

43-
//10msec time resolution
44-
//t seconds elapsed
43+
//t seconds elapsed 10msec time resolution
4544
const t = __
4645
.intervalSeq(Immutable.Range(), 10)
4746
.__((count) => (count * 10 / 1000));
4847
const x = t.__((t) => V0 * Math.cos(THETA) * t);
4948
const y = t.__((t) => V0 * Math.sin(THETA) * t - 1 / 2 * G * Math.pow(t, 2));
50-
//==============================================================
49+
//===================================================
5150
const Drawscale = 1; //1 dot = 1 meter
5251
const __seqEl = __([x, y]) //atomic update
53-
.__(([x, y]) => (
52+
.__(([x, y]) => (<circle r="3" fill="red"
53+
cx = {50 + x * Drawscale} cy = {250 - y * Drawscale}/>));
54+
return (
5455
<div>
5556
<svg height = "250" width = "100%">
56-
<circle r="3" fill="red"
57-
cx = {50 + x * Drawscale} cy = {250 - y * Drawscale}/>
57+
{__Component(__seqEl)}
5858
</svg>
59-
</div>));
60-
61-
return __Component(__seqEl);
59+
</div>);
6260
};
6361

6462
const ButtonComponent = () => {
@@ -67,11 +65,12 @@
6765
__clicked.t = true;
6866
};
6967

68+
7069
const __seqEl = __([__clicked])
7170
.__(() => (<div>{PhysicsComponent()}</div>));
7271

7372
return (<div>
74-
<div><button onClick={onClick}>Physics Start</button></div>
73+
<div><button onClick={onClick()}>Physics Start</button></div>
7574
{__Component(__seqEl)}
7675
</div>
7776
);

test.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,12 +8,13 @@
88
.log('timeengine test started...');
99

1010
const a = __();
11-
const b = __();
12-
const c = __([a, b]).__(([a, b]) => (a + b));
11+
const b = __([a]);
12+
// const c = __([a, b]).__(([a, b]) => (a + b));
1313

14+
//var c = a.__([b]);
1415
const timeseq1 = a.log('a');
1516
const timeseq2 = b.log('b');
16-
const timeseq3 = c.log('c');
17+
// const timeseq3 = c.log('c');
1718

1819
const timeseq4 = __.intervalSeq(Immutable.Range(0, 1), 1000)
1920
.__(() => {

timeengine.es

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
});
2121
seq.IndexOnTimestamp = {};
2222
seq.TimestampOnIndex = {};
23+
seq.done = 0;
2324
//-----------------
2425
Object.keys(__.api).map((api) => {
2526
seq[api] = __.api[api](__, seq, store);
@@ -41,22 +42,24 @@
4142
seq[seq.length] = seq.valOnT;
4243
}
4344
//----------------------
44-
Object.keys(seq.updatedFor).map((key) => {
45-
seq.updatedFor[key] = 1;
46-
});
47-
seq.us.map((u) => {
48-
//-------------------
49-
const dsAllUpdated = u.ds
50-
.map((d) => (d.updatedFor[u.id]))
51-
.reduce((a, b) => (a * b));
52-
if (dsAllUpdated === 1) {
53-
u.t = u.eq(tval); //propagate
54-
//--clear updated ds in non-interference way--
55-
u.ds.map((d) => {
56-
d.updatedFor[u.id] = 0;
57-
});
58-
}
59-
});
45+
if (seq.done === 0) {
46+
Object.keys(seq.updatedFor).map((key) => {
47+
seq.updatedFor[key] = 1;
48+
});
49+
seq.us.map((u) => {
50+
//-------------------
51+
const dsAllUpdated = u.ds
52+
.map((d) => (d.updatedFor[u.id]))
53+
.reduce((a, b) => (a * b));
54+
if (dsAllUpdated === 1) {
55+
u.t = u.eq(tval); //propagate
56+
//--clear updated ds in non-interference way--
57+
u.ds.map((d) => {
58+
d.updatedFor[u.id] = 0;
59+
});
60+
}
61+
});
62+
}
6063
}
6164
}
6265
});

timeengine.js

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
});
3434
seq.IndexOnTimestamp = {};
3535
seq.TimestampOnIndex = {};
36+
seq.done = 0;
3637
//-----------------
3738
Object.keys(__.api).map(function (api) {
3839
seq[api] = __.api[api](__, seq, store);
@@ -55,24 +56,26 @@
5556
seq[seq.length] = seq.valOnT;
5657
}
5758
//----------------------
58-
Object.keys(seq.updatedFor).map(function (key) {
59-
seq.updatedFor[key] = 1;
60-
});
61-
seq.us.map(function (u) {
62-
//-------------------
63-
var dsAllUpdated = u.ds.map(function (d) {
64-
return d.updatedFor[u.id];
65-
}).reduce(function (a, b) {
66-
return a * b;
59+
if (seq.done === 0) {
60+
Object.keys(seq.updatedFor).map(function (key) {
61+
seq.updatedFor[key] = 1;
6762
});
68-
if (dsAllUpdated === 1) {
69-
u.t = u.eq(tval); //propagate
70-
//--clear updated ds in non-interference way--
71-
u.ds.map(function (d) {
72-
d.updatedFor[u.id] = 0;
63+
seq.us.map(function (u) {
64+
//-------------------
65+
var dsAllUpdated = u.ds.map(function (d) {
66+
return d.updatedFor[u.id];
67+
}).reduce(function (a, b) {
68+
return a * b;
7369
});
74-
}
75-
});
70+
if (dsAllUpdated === 1) {
71+
u.t = u.eq(tval); //propagate
72+
//--clear updated ds in non-interference way--
73+
u.ds.map(function (d) {
74+
d.updatedFor[u.id] = 0;
75+
});
76+
}
77+
});
78+
}
7679
}
7780
}
7881
});

0 commit comments

Comments
 (0)