Giter VIP home page Giter VIP logo

Comments (4)

matt-kruse avatar matt-kruse commented on July 16, 2024

In every other programming environment I'm used to, a "session" attribute persists as long as the session exists, across multiple requests. You don't need to re-set it each time. So on creation of a new session, you may look up user details and persist them in the session, so every subsequent request will have access to it. That's the whole point of a session! Never have I see "session" attributes that automatically disappear after the next request.

That's why I copy them over, so you can set them once and they will get re-sent with each request. IMO, this is a very desirable feature. If you want to clear a session attribute, you can do response.session(key,null).

I guess I could make this optional, but I would still prefer to default it to enabled, because that's what makes sense to me. I'm open to hearing further arguments. :)

from alexa-app.

OverloadUT avatar OverloadUT commented on July 16, 2024

Oh I see, you thinking of them like cookies. "Here's an attribute, tell me what it is on every subsequent request." I can certainly see that as a way they could have been implemented. I doubt they'll change it to be that way because it would break ASKs already being approved. The ship has sailed! Plus it's trivial to persist any attributes that you want, and that puts more power control in the hands of the developer which is likely the desired outcome.

My main problem with what you're doing is this is a case where you are redefining the default behavior of how Alexa apps work, which I don't think is a module's business and actually makes it more difficult for a developer to switch to using your module. You're basically injecting your belief in how you think the Alexa SDK should have been made in to this implementation.

I think ideally someone should be able to simply move their logic from their own app to one managed by this module without having to change any of the fundamental logic. But with this default behavior, the user would need to rethink how they handled sessionAttributes to ensure that it still works.

Another reason it's undesirably is that someone reading the source code of an app built on alexa-app will likely not know about this redefined behavior and when trying to understand how the app works, will make (reasonable) false conclusions. If the app had a call in there saying "persist all session attributes" then it would be more semantically understandable.

from alexa-app.

matt-kruse avatar matt-kruse commented on July 16, 2024

I see your point, but I do disagree. Every web programmer I know will expect "session" attributes to actually persist for the whole session. That's how sessions work! So, yes, this module is a little opinionated in that way, but I think it will actually make life much easier for most developers. By default, it will behave in the way they naturally expect.

I've just added a new option for the next (2.1) release that I'm working on:

app.persistentSession=false;

This will turn off the default behavior.

from alexa-app.

OverloadUT avatar OverloadUT commented on July 16, 2024

Oh I hadn't seen this yet. Perfect!

from alexa-app.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.