Comments (5)
request.session(key) will return the session value, and response.session(key,value) will set a new one. You can still get to the sessionAttributes directly, but I find those utility methods to be more straight-forward.
from alexa-app.
But that still means it's impossible to get the current sessionsAttributes staged in the response via your utility method. At the very least response.session(key) should get the current value.
In javascript and especially node I'm not used to seeing getter and setter methods for no reason. Typically an object is just exposed and the user uses that directly. I only see downsides of this method, such as losing out on all operators. Consider the semantic readability of this (this would assume you would make response.session a getter as well):
// Using methods
response.session('totalScore', response.session('totalScore') + response.session('roundScore'));
// Using the object
response.session.totalScore += response.session.roundScore;
It's not huge yeah, but the latter is what you see everywhere in Javascript. By forcing the use of methods to set a variable, you lose out on all of the operators. For example, you can't delete
a parameter from the object right now. You can either set it to null
(which is not the same as non-existent, and will actually get put in to the JSON string) or set it as undefined
which is also, paradoxically, not the same as actually having it undefined. Javascript is kind of lame like that.
At the end of the day it's not a big deal so long as you leave response.response.sessionAttributes available to manipulate directly; I'm just trying to give feedback on making this thing a rock solid module that follows as close to node module standards (let's be honest and use that term very loosely ;) )
from alexa-app.
Like you said, everything is still exposed. The session methods are just shortcuts for common operations. In 2.1 I've added a response.clearSession() function, which either clears all response session data, or if passed a key it will clear just that key. I will add the ability to call response.session(key) as a getter, for convenience.
from alexa-app.
Cool, that'll work! If I want to globally disable the feature I should just be able to put response.clearSession() in pre(), right?
from alexa-app.
Or like I say in the other issue, app.persistentSession=false to disable it entirely. :)
from alexa-app.
Related Issues (20)
- Support for CanFulfillIntentRequest HOT 7
- Errors when using KeepAlive-style CloudWatch events HOT 5
- Patch for directive Dialog.Delegate HOT 2
- Cannot get directive display to work in Alexa skill. HOT 5
- Not able to use alexa-app HOT 2
- APL Support ? HOT 6
- VideoApp Directive HOT 1
- alexa-verifier-middleware HOT 1
- request.userId returning the wrong user HOT 3
- Multi turn dialog
- How we can get user permissions list?
- ssml lowercase
- Firebase Promise Failure HOT 2
- Support for In-Skill Purchases (ISP)? HOT 1
- INVALID_REQUEST_TYPE HOT 3
- Chained callbacks not working. HOT 2
- Issues testing locally the Skill: alexa-app + express + ngrok HOT 2
- Xxxxx
- REPLACE_ALL play behavior has no effect HOT 1
- Catch User Profile Data
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alexa-app.