-
Notifications
You must be signed in to change notification settings - Fork 0
/
timeengine-react.jsx
54 lines (50 loc) · 1.22 KB
/
timeengine-react.jsx
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
/*global React timeengine __ Immutable __Element*/
//this file need to be transpiled to js
//npm test
(() => {
"use strict";
const mode = typeof module !== "undefined" && module.exports;
const React = (mode)
? require("react")
: window.React;
const ReactDOM = (mode)
? require("react-dom")
: window.ReactDOM;
const __ = (mode)
? require("timeengine")
: window.__;
//***React state with life cycle is stateless sequence*****
const __Element = (__seqEl, f = () => 0) => {
class SeqComponent extends React.Component {
constructor() {
super();
this.state = {
seqEl: __seqEl.t
};
const __timeseq = __([__seqEl])
.__(([val]) => {
this.setState({
seqEl: val
});
f(ReactDOM.findDOMNode(this).children[0]);
return true;
});
}
componentWillUnmount() {
__seqEl.done = 1;
}
render() {
return (<span>{this.state.seqEl}</span>);
}
}
return (<SeqComponent/>);
};
//------------------
const binder = (mode)
? (() => {
module.exports = __Element;
})()
: (() => {
window.__Element = __Element;
})();
})();