Options
All
  • Public
  • Public/Protected
  • All
Menu

Namespace stores

Provides methods for storing information on the client's machine. The persistence period will vary based on the storage type and configuration.

// esm
import { stores } from '@paychex/core';

// cjs
const { stores } = require('@paychex/core');

// iife
const { stores } = window['@paychex/core'];

// amd
require(['@paychex/core'], function({ stores }) { ... });
define(['@paychex/core'], function({ stores }) { ... });

Index

Functions

  • An in-memory store whose contents will be cleared each time the user navigates away from the page or refreshes their browser.

    NOTE: Objects are serialized to JSON during storage to ensure any modifications to the original object are not reflected in the cached copy as a side-effect. Retrieving the cached version will always reflect the object as it existed at the time of storage. However, some property types cannot be serialized to JSON. For more information, read this.

    example
    import { fetch, createRequest } from '~/path/to/datalayer';

    const operation = {
    base: 'reports',
    path: 'jobs/:id'
    };

    const store = stores.memoryStore();
    const cache = stores.utils.asDataCache(store);
    const pipeline = data.utils.withCache(fetch, cache);

    export async function loadData(id) {
    const params = { id };
    const request = createRequest(operation, params);
    const response = await pipeline(request).catch(errors.rethrow(params));
    return response.data;
    }

    Returns Store

    A Store that is not persisted. The store will be cleared when the site is refreshed or navigated away from.