pinafore/routes/_store/mixins/instanceMixins.js
Nolan Lawson 8d5690d63d
remove get() with string from Svelte calls (#169)
* remove get() with string pt 1

* remove get() with string pt 2

* fix typo

* fix some null exceptions in get()

* fixup code style
2018-04-19 09:37:05 -07:00

24 lines
867 B
JavaScript

export function instanceMixins (Store) {
Store.prototype.setComposeData = function (realm, obj) {
let { composeData, currentInstance } = this.get()
let instanceNameData = composeData[currentInstance] = composeData[currentInstance] || {}
instanceNameData[realm] = Object.assign(instanceNameData[realm] || {}, obj)
this.set({composeData})
}
Store.prototype.getComposeData = function (realm, key) {
let { composeData, currentInstance } = this.get()
return composeData[currentInstance] &&
composeData[currentInstance][realm] &&
composeData[currentInstance][realm][key]
}
Store.prototype.clearComposeData = function (realm) {
let { composeData, currentInstance } = this.get()
if (composeData && composeData[currentInstance]) {
delete composeData[currentInstance][realm]
}
this.set({composeData})
}
}