# Snapshot

npm

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

# Installation

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

Install @harlem/plugin-snapshot:

npm install @harlem/plugin-snapshot
1

Or if you're using Yarn:

yarn add @harlem/plugin-snapshot
1

# Usage

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
2
3
4
5
6
7
8
9
10
11
12

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
2
3
4
5
6
7
8
9

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
1
2
3
4