@harlem/plugin-snapshot

The official snapshot plugin for Harlem

Usage no npm install needed!

<script type="module">
  import harlemPluginSnapshot from 'https://cdn.skypack.dev/@harlem/plugin-snapshot';
</script>

README

Harlem

Harlem Snapshot Plugin

npm

This is the official Harlem plugin for taking state snapshots and applying them when convenient.

Getting started

Before installing the snapshot plugin make sure you have installed @harlem/core.

  1. Install @harlem/plugin-snapshot:
npm install @harlem/plugin-snapshot

Or if you're using Yarn:

yarn add @harlem/plugin-snapshot
  1. Create an instance of the plugin and register it with Harlem:
import App from './app.vue';

import harlem from '@harlem/core';
import createSnapshotPlugin from '@harlem/plugin-snapshot';

createApp(App)
    .use(harlem, {
        plugins: [
            createSnapshotPlugin()
        ]
    })
    .mount('#app');
  1. Call the snapshot method with the name of the store you wish to snapshot:
import {
    snapshot
} from '@harlem/plugin-snapshot';

export default function() {
    const snap = snapshot('my-store');

    // ...
}
  1. Apply the snapshot:
const snap = snapshot('my-store');

snap.apply(); // Apply the snapshot over the top of current state
snap.apply(true) // Replace state with the current snapshot