alexa / alexa-skills-kit-sdk-for-nodejs

The Alexa Skills Kit SDK for Node.js helps you get a skill up and running quickly, letting you focus on skill logic instead of boilerplate code.
Apache License 2.0
3.12k stars 737 forks source link

feat: add a defaultAttributes parameter in getPersistentAttributes #626

Closed hideokamoto closed 4 years ago

hideokamoto commented 4 years ago

Description

To add a new parameter named defaultAttributes. We can easy to initialize persistence attributes to use it.

Motivation and Context

Before

We have to initialize persistence attributes by own code.

let attributes = await attributesManager.getPersistentAttributes()
if (!attributes) {
  attributes = {
    invocationCount: 1
  }
  attributesManager.setPersistenceAttributes(attributes)
}

After

We can easy to initialize the attributes

const attributes = await attributesManager.getPersistentAttributes(true, { invocationCount: 1 } )

Testing

See my test code in this PR.

Screenshots (if appropriate)

Types of changes

Checklist

License

ShenChen93 commented 4 years ago

@hideokamoto

Thanks for this PR. This feature looks reasonable and useful, will do the merge and get it out on next SDK release.

Thanks, Shen