« first day  last day (15 days later) » 

9:05 PM
Hey DJ
Thought I'd move this into chat for my last question.
But here's what I'm talking about pastebin.com/n2rvbsNd
So, originally I was calling this.emit() within the callback. But of course, this would then be referring to the callback and no longer the global scope and .emit() would be invalid.
What I did now was create const alexa = this before and outside of the callback function, so that when I'm inside the function, I can call alexa.emit()
In the end, I only want .emit() to run once it receives the response in the callback, which is why I was placing the .emit() call in the callback. But my question is whether or not this is a "hacky" solution or good practice.
 
9:48 PM
Question: why is your global scope an event emitter?
Like is all of this wrapped in some sort of Alexa object?
Regardless, if this works, then my questions don't matter. This is not hacky, and in fact it used to be common practice to say var self = this in order to preserve context when moving inside new function scopes.
But with JavaScript ES6, you can use arrow function syntax, which does not create a new this
So you might rewrite your code to look like this
Very subtle difference ... but assuming the code you just shared with me works as expected, then this should as well without the need to say var alexa = this
 
 
1 hour later…
11:05 PM
This is just a Handlers.js file that is exported and attached to an alexa object in my index.js
I'm using the format provided by Alexa's github
 

« first day  last day (15 days later) »