-
Notifications
You must be signed in to change notification settings - Fork 43
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pipes - Lindsey - Ada Trader #23
base: master
Are you sure you want to change the base?
Conversation
Ada TraderWhat We're Looking For
|
initialize(attributes) { | ||
this.buy = attributes.buy; | ||
this.targetPrice = attributes.targetPrice | ||
this.quote = attributes.activeQuote; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that the Order
knows which quote it's for. It's possible to achieve the same behavior through the bus, but the resulting code ends up being much more complex and hard to read.
|
||
quoteCheck: function(e) { | ||
if (this.buy && parseFloat(this.targetPrice) > parseFloat(this.quote.get('price'))) { | ||
this.bus.trigger(`buyMe${this.quote.attributes.symbol}`, this.quote.attributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good use of a model function.
Since you know what quote you need to buy/sell, it might be cleaner to call the this.quote.buy()
or this.quote.sell()
directly here rather than passing messages through the bus.
buyOrder: function(event) { | ||
event.preventDefault(); | ||
const orderData = {}; | ||
orderData['symbol'] = this.$(`[name=symbol]`).val(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function and sellOrder
are almost identical. Could you consolidate the two?
Ada Trader
Congratulations! You're submitting your assignment!
Comprehension Questions