How to use the localforage.INDEXEDDB 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 xyfir / illuminsight / lib / app / index.ts View on Github external
enve: Illuminsight.Env;
    }
  }
}
/* eslint-enable */

if ('serviceWorker' in navigator) {
  window.addEventListener('load', () => {
    navigator.serviceWorker
      .register('/sw.js')
      .then((r) => console.log('SW', r))
      .catch((e) => console.error('SW', e));
  });
}

localForage.config({ driver: localForage.INDEXEDDB, name: 'illuminsight' });

render(React.createElement(hot(App)), document.getElementById('content'));
github datorama / akita / angular / playground / src / app / app.component.ts View on Github external
import { Component } from '@angular/core';
import { persistState } from '@datorama/akita';
import { debounceTime } from 'rxjs/operators';
import * as localForage from 'localforage';

localForage.config({
  driver: localForage.INDEXEDDB,
  name: 'Akita',
  version: 1.0,
  storeName: 'akita_playground'
});

@Component({
  selector: 'app-root',
  templateUrl: './app.component.html',
  styleUrls: ['./app.component.css']
})
export class AppComponent {
  ngOnInit() {
    persistState({
      key: 'akitaPlayground',
      include: ['auth.token', 'todos'],
      // storage: localForage,
github peerplays-network / BookiePro / src / store / configureStore.js View on Github external
applyMiddleware(
      thunk,
      routerMiddleware(hashHistory)
    ),
    autoRehydrate()
  );

  const store = createStore(
    rootReducer,
    initialState,
    enhancer,
  );

  // Configure localforage Indexeddb setting ( for redux-persist)
  localforage.config({
    driver      : localforage.INDEXEDDB, // Force WebSQL; same as using setDriver()
    name        : 'bookie',
    version     : 1.0,
    // storeName   : 'store_name', // Should be alphanumeric, with underscores.
    description : 'desc'
  });
  localforage.setDriver(localforage.INDEXEDDB);

  // Create filter to whitelist only subset of the redux store
  const subsetFilterTransform = createTransform(
    (inboundState, key) => {
      if (key ==='rawHistory') {
        // Only persist rawHistoryByAccountId for history reducer
        const savedState = inboundState.filter((v, k) => k === 'rawHistoryByAccountId');
        return savedState;
      } else {
        return inboundState;
github rahatarmanahmed / nanopush / client / model.js View on Github external
/* eslint-env browser */
const localforage = require('localforage')
localforage.config({ driver: localforage.INDEXEDDB })

const { urlBase64ToUint8Array } = require('./util')

const serviceWorkerSupported = 'serviceWorker' in navigator
const applicationServerKey = urlBase64ToUint8Array(process.env.applicationServerKey)

const getNotificationPermission = () =>
  'Notification' in window ? window.Notification.permission : 'unsupported'

function fetchNewToken () {
  return fetch('token')
  .then((result) => result.json())
  .then(({ token }) => token)
}

function getToken () {
github rate-engineering / rate3-monorepo / packages / demo / token-swap / src / sagas / network.ts View on Github external
import { fromTokenAmount, IAction } from '../utils/general';
import localforage from 'localforage'; // tslint:disable-line:import-name
import { ETH_USER } from '../constants/defaults';
import moment from 'moment';
const HORIZON = 'https://horizon-testnet.stellar.org';

const STELLAR_USER = 'GAOBZE4CZZOQEB6A43R4L36ESZXCAGDVU7V5ECM5LE4KTLDZ6A4S6CTY';
const STELLAR_USER_SECRET = 'SA5WYQ7EJNPCX5GQHZHGNHE5XZLT42SL6LAEMIVO6WKC6ZR4YENAEZQV';

const STELLAR_ISSUER = 'GAC73JYYYVPAPVCEXDOH7Y2KFT6GUSJWJKKCZM52UMIXTZG2T6D5NRRV';
const STELLAR_ISSUER_SECRET = 'SA6RJV2U5GUK3VYM5CHGATLXEJIDZ37YRF5MJDD5CGKT4LWKMGDDSOOM';

const STELLAR_DISTRIBUTOR = 'GA3V7T4P6KQJEPEZTVRUJWLZ3XB262BIWXYDZJ4SIS6AOPCX4KNIGGDH';
const STELLAR_DISTRIBUTOR_SECRET = 'SD676EDAREHFTLX4MYZCPPZDMV5D44PLP42ORGBHOD5PV5ONXPTIOTLK';
localforage.config({
  driver      : localforage.INDEXEDDB, // Force WebSQL; same as using setDriver()
  name        : 'token-swap-demo',
  version     : 1.0,
  size        : 4980736, // Size of database, in bytes. WebSQL-only for now.
  storeName   : 'keyvaluepairs', // Should be alphanumeric, with underscores.
  description : 'stores the approval list',
});
function* getBalance() {
  try {
    const getWeb3 = state => state.network.web3Obj;
    const web3 = yield select(getWeb3);
    const address = web3.eth.accounts.wallet[0].address;
    const balance = yield web3.eth.getBalance(address);
    return balance;
  } catch (e) {
    yield put({ type: networkActions.SET_ERROR, payload: JSON.stringify(e) });
    throw e;
github workswithweb / MQTTBox / src / app / services / MqttClientDbService.js View on Github external
}

    saveMqttClientSettings(obj) {

        Q.invoke(this.db,'setItem',obj.mcsId,obj).done();
github workswithweb / MQTTBox / src / app / services / MqttLoadDbService.js View on Github external
this.loadInstanceDataDb = localforage.createInstance({name:"MQTT_LOAD_INSTANCE_DATA",driver:localforage.INDEXEDDB});
    }

    saveMqttLoadSettings(obj) {

        Q.invoke(this.loadSettingsDb,'setItem',obj.mcsId,obj).done();
github VirgilSecurity / virgil-sdk-javascript / src / key-storage / adapters / localforage-storage.js View on Github external
'use strict';

var localforage = require('localforage');
var toArrayBuffer = require('to-arraybuffer');
var utils = require('../../shared/utils');

var defaults = {
	driver: localforage.INDEXEDDB
};

/**
 *  Creates a storage adapter that uses "localforage" for persistence.
 *  @param {(Object|string)} config - The storage configuration options.
 *  @param {string} [config.name='VirgilSecurityKeys'] - The storage name.
 *  @returns {StorageAdapter}
 * */
function localforageStorage (config) {
	config = utils.assign({}, defaults, config || {});

	var store = localforage.createInstance(config);

	return {

		/**
github portinariui / portinari-angular / projects / storage / src / lib / services / po-storage.service.ts View on Github external
return driverOrder.map(driver => {
      switch (driver) {
        case 'indexeddb':
          return LocalForage.INDEXEDDB;
        case 'websql':
          return LocalForage.WEBSQL;
        case 'localstorage':
          return LocalForage.LOCALSTORAGE;
        default:
        return driver;
      }
    });
  }
github workswithweb / MQTTBox / src / app / services / MqttLoadSettingsService.js View on Github external
constructor() {
        super();
        this.dbWorker = new Worker('./js/MqttLoadSettingsDbWorker.js');
        this.MqttLoadDataDbWorker = new Worker('./js/MqttLoadDataDbWorker.js');
        this.loadDataDb = localforage.createInstance({name:MqttLoadConstants.DB_MQTT_LOAD_DATA,driver:localforage.INDEXEDDB});
        this.mqttLoadSettingObjs = {};
        this.connWorkers = {};

        this.registerToAppDispatcher = this.registerToAppDispatcher.bind(this);
        this.workerMessageListener = this.workerMessageListener.bind(this);
        this.syncMqttLoadSettingsCache = this.syncMqttLoadSettingsCache.bind(this);
        this.saveMqttLoadSettings = this.saveMqttLoadSettings.bind(this);
        this.getAllMqttLoadSettingsData = this.getAllMqttLoadSettingsData.bind(this);
        this.getMqttLoadSettingsDataByBsId = this.getMqttLoadSettingsDataByBsId.bind(this);
        this.startMqttLoad = this.startMqttLoad.bind(this);
        this.stopMqttLoad = this.stopMqttLoad.bind(this);
        this.updateMqttLoadData = this.updateMqttLoadData.bind(this);
        this.mqttLoadFinished = this.mqttLoadFinished.bind(this);
        this.getMqttLoadDataByInstanceId = this.getMqttLoadDataByInstanceId.bind(this);
        this.getMqttLoadDataByInstanceIds = this.getMqttLoadDataByInstanceIds.bind(this);