Amy Cash - Pipes - Ada Trader #41
Amy Cash - Pipes - Ada Trader #41cashmonger wants to merge 28 commits intoAda-C8:masterfrom cashmonger:master
Conversation
Ada TraderWhat We're Looking For
|
| buy() { | ||
| // Implement this function to increase the price by $1.00 | ||
| let buyPrice = this.get('price'); | ||
| let newPrice = buyPrice + 1.00; |
There was a problem hiding this comment.
We could probably use const here instead of let.
| let stringPrice = this.$(`#order-entry-form input[name=price-target]`).val(); | ||
| orderData["targetPrice"] = parseFloat(stringPrice); | ||
| orderData["buy"] = buy; | ||
| this.bus.trigger('get_quote', this.model); |
There was a problem hiding this comment.
It looks like triggering this event isn't doing anything, because there are no objects that are listening for it.
| this.quoteList.each((quote) => { | ||
| if (orderData['symbol'] == quote.get('symbol') ) { | ||
| orderData['quote'] = quote; | ||
| } |
There was a problem hiding this comment.
This could also be written as:
orderData.quote = this.quoteList.findWhere({ symbol: orderData.symbol });| this.recordTrade(false) | ||
| this.model.sell(); | ||
| }, | ||
| recordTrade(buy) { |
There was a problem hiding this comment.
I think the logic in this function could be moved into the Quote model, and have it be run as part of buy() or sell().
This would allow it to be tested more easily, and reduces the coupling between this view and its model.
|
|
||
| const quoteListView = new QuoteListView({ | ||
| el: '#quotes-container', | ||
| model: quoteList, |
There was a problem hiding this comment.
By passing quoteList here we are creating a view for a collection of quotes that is not connected to the simulator at all (and thus there appears to be no automatic change in prices).
If we insted write model: quotes, for this line then we'll be connecting this QuoteListView to the same collection of quotes as the simulator receives, which should solve the issue.
Ada Trader
Congratulations! You're submitting your assignment!
Comprehension Questions