GeoXpWebStorage plugin provides persistent storage to GeoXpCore using cookies.
It can be used in any web browser environment.
# npm
npm install @geoxp/web-storage
# yarn
yarn add @geoxp/web-storage
GeoXpWebStorage is intended for use as a singleton instance. It has to be created once the application starts, based on a configuration object.
// import modules
import GeoXpCore from '@geoxp/core';
import GeoXpWebStorage from '@geoxp/web-storage';
// create configuration object
const { coreConfig, storageConfig } = { /* your configuration here */ };
// create the GeoXp instances
const geoXpCore = new GeoXpCore(coreConfig);
const geoXpWebStorage = new GeoXpWebStorage(geoXpCore, storageConfig);
GeoXpWebStorage, once created, works without any external intervention. To provide this high level of automation, it has to be accurately configured according to the desired application. The configuration is provided as a json object.
config: {
cookiePrefix: string // prefix to append to pattern cookie name
deleteOnLastSpot: boolean // self delete when last spot is visited
deleteOnCompletion: boolean // self delete when all spots have been visited
expiration: number // cookies expiration [minutes] - deafult 5 - set to 0 to exclude cookies
}
expiration
partams determines how long the cookies will be saved in the browser. Default is 5 minutes. Set this value to 0 if you want cookies to be deleted at each reload.
// create the GeoXp instances
const geoXpCore = new GeoXpCore(coreConfig);
const geoXpWebStorage = new GeoXpWebStorage(geoXpCore, storageConfig);
// refresh all geoXp state with the given configuration
geoXpCore.reload(coreConfig);
geoXpWebStorage.reload(storageConfig);
// Clears all stored cookies
geoXpWebStorage.clearAll();
All GeoXpWebStorage methods are available in the documentation page.
To contribute to this project, fork the repository, work on a development branch and open a MR. Remember to update the changelog (CHANGELOG.md)!
For repo admins To release a new version, follow these steps:
- verify and test changes
- verify changelog has been updated
- merge MR in
main
- publish a new version
- create a new release in the release section