-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathSubscriberElement.js
40 lines (38 loc) · 1.24 KB
/
SubscriberElement.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
define(['lib/react'], function(React) {
return React.createClass({
subscribe: function() {
if (typeof damJSStreamLink !== "undefined") {
damJSStreamLink.subscribe(this.state.subject,
{
onSubscriptionStatus : function(subscription, event) {
console.log(subscription.getSubject() + " is now " + event.getStatus());
},
onSubscriptionError : function(subscription, event) {
console.log("Error: Subject " + subscription.getSubject() + " is " + event.getError());
},
onRecordUpdate : function(subscription, event) {
console.log(event.getSubject(), event.getFields())
}
}
)
} else {
alert('Make a real subscription first!');
}
},
getInitialState:function() {
return {subject: "/FX/EURUSD/SPOT/EUR/100"}
},
setSubject:function(e) {
this.setState({
subject: e.target.value
})
},
render: function() {
return React.DOM.div({},
React.DOM.button({onClick: this.props.back}, "Back"),
React.DOM.input({value: this.state.subject, onChange: this.setSubject}),
React.DOM.button({onClick: this.subscribe},"Subscribe")
);
}
});
});