January 2020
Intermediate to advanced
530 pages
11h 11m
English
Similar to the orderbook, we need to set an event stream for the successful trades in the network.
To do so, we use the following setTrades method:
setTrades = () => { let app = this; var tradeHandler = function (traderesponse) { var tradesList = app.state.tradesList; tradesList.push(traderesponse); app.setState ({ tradesList }); }; var es = this.server.trades() .cursor('now') .stream({ onmessage: tradeHandler })};
The internal tradeHandler method is called any time a new message is published to the trades event stream. The tradeHandler function updates the list of trades stored in the state variable, tradesList.
The tradesList array is mapped and rendered by the Trades.js component and displayed ...
Read now
Unlock full access