How to use the localforage.createInstance function in localforage

To help you get started, we’ve selected a few localforage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DivanteLtd / vue-storefront / core / store / lib / storage.ts View on Github external
public recreateDb () {
    if (this._localForageCollection._config) {
      const existingConfig = Object.assign({}, this._localForageCollection._config)
      if (existingConfig.storeName) {
        // localForage.dropInstance(existingConfig) // drop the store and create the new one
        const destVersionNumber = this._localForageCollection && this._localForageCollection._dbInfo ? this._localForageCollection._dbInfo.version + 1 : 0
        if (destVersionNumber > 0) {
          this._localForageCollection = localForage.createInstance({ ...existingConfig, version: destVersionNumber })
        } else {
          this._localForageCollection = localForage.createInstance(existingConfig)
        }
        Logger.log('DB recreated with', existingConfig, destVersionNumber)()
      }
    }
  }
github Coding / WebIDE-Frontend / app / persist.js View on Github external
import { autorunAsync, createTransformer, toJS as mobxToJS } from 'mobx'
import localforage from 'localforage'
import config from './config'
import { hydrate as editorTabHydrate } from './components/Tab/actions'
import { hydrate as settingsHydrate } from './components/Setting/state'
import { hydrate as pluginsHydrate } from './components/Plugins/actions'
import fileState, { hydrate as fileHydrate } from './commons/File/state'


const mainStore = localforage.createInstance({
  name: 'mainProject'
})

// store needed to persist
// the custom transform func
// the delay to set

function persistStore (store, transform) {
  autorunAsync(() => {
    const customTransform = transform || createTransformer(store => mobxToJS(store))
    const transformedStore = customTransform(store)
        // 初次等spacekey出现存
    if (config.spaceKey && !mainStore._config.storeName) {
      mainStore.config({ storeName: config.spaceKey })
    } else if (mainStore._config.storeName && (config.globalKey || !config.isPlatform)) {
      if (config.hasRehydrated) {
github joshwcomeau / beatmapper / src / store / persistence-engine.js View on Github external
const createEngine = (whitelist = []) => {
  // This `createEngine` function modified
  // https://raw.githubusercontent.com/mathieudutour/redux-storage-engine-localforage/master/src/index.js
  const reduxStore = localforage.createInstance({
    name: 'BeatMapper redux state',
  });

  function rejectWithMessage(error) {
    return Promise.reject(error.message);
  }

  reduxStore.config(config);

  let engine = {
    load() {
      return reduxStore
        .getItem(key)
        .then(jsonState => JSON.parse(jsonState) || {})
        .catch(rejectWithMessage);
    },
github MicroPad / Web / app / src / react-web / index.tsx View on Github external
console.warn(`Couldn't set domain for resolving CORS. If this is prod change 'MICROPAD_URL'.`);
}

const baseReducer: BaseReducer = new BaseReducer();
export const store = createStore(
	baseReducer.reducer,
	baseReducer.initialState,
	composeWithDevTools(applyMiddleware(epicMiddleware))
);

export const NOTEPAD_STORAGE = localforage.createInstance({
	name: 'MicroPad',
	storeName: 'notepads'
});

export const ASSET_STORAGE = localforage.createInstance({
		name: 'MicroPad',
		storeName: 'assets'
});

export const SYNC_STORAGE = localforage.createInstance({
	name: 'MicroPad',
	storeName: 'sync'
});

export const TOAST_HANDLER = new ToastEventHandler();

export function getStorage(): { [name: string]: LocalForage } {
	return {
		notepadStorage: NOTEPAD_STORAGE,
		assetStorage: ASSET_STORAGE,
		syncStorage: SYNC_STORAGE
github DivanteLtd / vue-storefront / core / modules / cart / hooks / beforeRegistration.ts View on Github external
export function beforeRegistration ({ Vue, config, store, isServer }) {
  const storeView = currentStoreView()
  const dbNamePrefix = storeView.storeCode ? storeView.storeCode + '-' : ''

  Vue.prototype.$db.cartsCollection = new UniversalStorage(localForage.createInstance({
    name: (config.storeViews.commonCache ? '' : dbNamePrefix) + 'shop',
    storeName: 'carts',
    driver: localForage[config.localForage.defaultDrivers['carts']]
  }))
}
github mangalam-research / wed / lib / wed / savers / localforage.ts View on Github external
export function config(): LocalForage {
  return localforage.createInstance({
    name: "wed",
    storeName: "files",
  });
}
github DivanteLtd / vue-storefront / src / modules / claims / hooks / beforeRegistration.ts View on Github external
export function beforeRegistration ({ Vue, config, store, isServer }) {
  const storeView = currentStoreView()
  const dbNamePrefix = storeView.storeCode ? storeView.storeCode + '-' : ''

  Vue.prototype.$db.claimsCollection = new UniversalStorage(localForage.createInstance({
    name: (config.storeViews.commonCache ? '' : dbNamePrefix) + 'shop',
    storeName: 'claims',
    driver: localForage[config.localForage.defaultDrivers['claims']]
  }))
}
github mangalam-research / wed / lib / wed / savers / localforage.js View on Github external
function config() {
    return localforage.createInstance({
      name: "wed",
      storeName: "files",
    });
  }
github creately / rxdata / src / persistors / localforage.ts View on Github external
protected _createLocalForage(name: string): any {
    return LocalForage.createInstance({ name });
  }