Plugins
Plugins for stash-it are things that can influence the data that flows through cache instance's methods. Plugins can also add new functionality (extend the API).
{
hooks: [],
createExtensions: ({ cacheInstance, getPreData, getPostData }) => {}
}How to use a plugin? What do I get from it?
import createDebugPlugin from 'stash-it-plugin-debug';
// assuming that you already have cache instance
const debugPlugin = createDebugPlugin(console.log);
const cacheWithPlugins = cache.registerPlugins([ debugPlugin ]);
// without the plugin, this method would not be here
cacheWithPlugins.runDiagnostics(); // runs the diagnostics
cache.runDiagnostics(); // error, runDiagnostics is not a functionLast updated