Just as a quick tip: If you need simple key-value-based storage for your plugin, I’ve written a little helper which serves as an abstraction layer for dealing with this.
You can find it at https://github.com/pklaschka/xd-storage-helper. It is MIT-Licensed and automatically serializes “serializable” objects (via JSON.stringify()). Additionally, instead of returning “null” when nothing is stored, you can pass it a default value that gets returned and saved when nothing was saved in this key (so you don’t have to deal with such special cases if you don’t want to).
I gave this repo (and a few others) a shoutout on stage at the Adobe Open Source Summit last week. I’ve got a blog post coming that will link to it as well.
Thanks for the contributions you’re making back to the community through open source projects!
I’m excited to announce that I’ve just published the storage helper to npm, so you can also easily integrate it when you have a bundler like webpack configured for your plugin. Then, you can just run
I just fixed a small, but pretty severe bug, that lead to the data not actually getting saved (that had happened because I had refactored something ). Therefore, if it didn’t work for you before, please reinstall the package and it should work as expected (I’ve now also added some Unit tests to make sure that doesn’t happen again)…
And – yet another update . I’ve now included typescript definitions (to use it with typescript) and improved the performance of reading operations (i.e. storageHelper.get(...) – it now doesn’t read the contents of the file again every time .get() gets called).