3.11.0 • Published 4 years ago

@ask-utils/labo v3.11.0

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

ASK Utils Labo

npm version License: MIT Maintainability Test Coverage Build Status logo

https://ask-utils.dev

Experimental modules of ask-utils

Getting started

$ npm i -S @ask-utils/labo

Features

PersistentAttributesManager

Wrapper class of PersistentAttributesManager to handle the props more easily.

Usage

const persistentAttributesManager = PersistanteAttributesManager.getInstance(handlerInput.attributesManager)
await persistentAttributesManager.updatePersistentAttributes({
    name: 'John'
})
await persistentAttributesManager.save()

Auto merge the props

await persistentAttributesManager.updatePersistentAttributes({
    name: 'John',
    count: 1,
})
await persistentAttributesManager.save()


await persistentAttributesManager.updatePersistentAttributes({
    message: 'hello',
    count: 2,
})
await persistentAttributesManager.save()

console.log(await persistentAttributesManager.getPersistentAttributes())

{
    name: 'John',
    count: 2,
    message: 'hello',
}

Detect should call AWS APIs

If no property has been updated, it will not call AWS API.

const persistentAttributesManager = PersistanteAttributesManager.getInstance(handlerInput.attributesManager)

// NOTHING TO DO
await persistentAttributesManager.save()

await persistentAttributesManager.updatePersistentAttributes({
    name: 'John'
})
// CALL attributeManager.savePersistentAttributes to save the update
await persistentAttributesManager.save()

// NOTHING TO DO
await persistentAttributesManager.save()