当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript localforage.createInstance函数代码示例

本文整理汇总了TypeScript中localforage.createInstance函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createInstance函数的具体用法?TypeScript createInstance怎么用?TypeScript createInstance使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了createInstance函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: constructor

    /**
     * Creates an instance of GitHubService.
     * Registers Offline, Online listeners to get the
     * HTTP post/update/delete request queue
     * @memberof GitHubService
     */
    public constructor() {
        // only initially works on older Firefox
        this._IsOnline = window.navigator.onLine || !(window['mozInnerScreenX'] == null);

        this._LiveLocalForage = localforage.createInstance({name: "live"});
        this._QueueLocalForage = localforage.createInstance({name: "queue"});

        window.addEventListener("online",this.syncChangesToServer.bind(this));
        window.addEventListener("offline",this.handleOfflineEvent.bind(this));
    }
开发者ID:,项目名称:,代码行数:16,代码来源:

示例2: constructor

 constructor(params?: Partial<LocalBackendClient>) {
   super(params);
   this.client = LocalForage.createInstance({
     driver: LocalForage.INDEXEDDB,
     name: 'scripsi'
   });
 }
开发者ID:luketurner,项目名称:scripsi,代码行数:7,代码来源:local.ts

示例3: constructor

 constructor() {
   if (!Storage.INSTANCE && !Config.isServer) {
     this.storage = localforage.createInstance({
       name: 'storage',
     });
     this.storage.setItem('timestamp', new Date());
   }
   Storage.INSTANCE = this;
 }
开发者ID:danielwii,项目名称:asuna-admin,代码行数:9,代码来源:storage.ts

示例4: countBy

  filter,
  groupBy,
  length,
  pipe,
  prop,
  memoize,
  reverse,
  sortBy,
  split,
} from 'ramda';
import { MinimalWordGraph, QueryBuilder } from '../WordGraph';

import url from './TWL06.txt';

const store = localForage.createInstance({
  name: 'twl',
});

const countChars = (w: string) => countBy(split('') as any, w as any);
const groupByLength = (
  w: string[],
): {
  [key: number]: string[];
} => groupBy(length as any, w as any) as any;

const isValid = curry((rack: string, word: string) => {
  const rackCount = countChars(rack);
  const wordCount = countChars(word);

  for (let key of Object.keys(rackCount)) {
    if (wordCount[key] > rackCount[key]) {
开发者ID:kerlends,项目名称:word-solver,代码行数:31,代码来源:solver.worker.ts

示例5:

 LocalForage.defineDriver(CordovaSQLiteDriver).then(() => {
     db = LocalForage.createInstance(config);
 })
开发者ID:scunningham777,项目名称:SelecQuest,代码行数:3,代码来源:storage.ts

示例6: WebSocket

import * as localforage from 'localforage';
import * as RichText from 'rich-text';
import { Connection, types } from 'sharedb/lib/client';

types.register(RichText.type);

// Open WebSocket connection to ShareDB server
const socket = new WebSocket(getWebSocketDocUrl());
const connection = new Connection(socket);
const store = localforage.createInstance({ name: 'documents' });

addEventListener('message', event => {
  const projectId = event.data.projectId as string;
  const collection = event.data.slug as string;
  const docSetIds = event.data.docSetIds as string[];
  // update documents in cache
  for (const docSetId of docSetIds) {
    updateDocumentCache(collection, docSetId, 'source', projectId);
    updateDocumentCache(collection, docSetId, 'target', projectId);
  }
  // remove deleted documents from cache
  const toRemove: string[] = [];
  store.iterate<any, any>(value => {
    if (value.projectId === projectId && !docSetIds.includes(getDocSetId(value.id))) {
      toRemove.push(value.id);
    }
  }).then(() => {
    for (const docId of toRemove) {
      store.removeItem(docId).then(() => console.log('Removed document ' + docId + ' from cache'));
    }
  });
开发者ID:sillsdev,项目名称:web-languageforge,代码行数:31,代码来源:document-cache.worker.ts

示例7: removeItem

import * as localForage from 'localforage'

const appStore = localForage.createInstance({
  // driver: localForage.INDEXEDDB,
  name: 'AppStore',
  version: 1.0,
})

const keyRegistry = {
  session: 'session',
  trainingOfflinePuzzles: 'training.offlinePuzzles',
}

type Key = keyof typeof keyRegistry

export default {
  getItem<T>(key: Key): Promise<T | null> {
    return appStore.getItem(keyRegistry[key])
  },
  setItem<T>(key: Key, value: T): Promise<T> {
    return appStore.setItem(keyRegistry[key], value)
  },
  removeItem(key: Key): Promise<void> {
    return appStore.removeItem(keyRegistry[key])
  }
}
开发者ID:mbensley,项目名称:lichobile,代码行数:26,代码来源:asyncStorage.ts

示例8:

 LocalForage.defineDriver(CordovaSQLiteDriver).then(() => {
   this.db = LocalForage.createInstance({
     name: this.config.get('storage.name')
   });
 }).then(() => {
开发者ID:ngKit,项目名称:ngKit,代码行数:5,代码来源:local.ts

示例9: require

const localForage: LocalForage = require('localforage');

const localStorage: LocalForage = localForage.createInstance({
    driver: localForage.LOCALSTORAGE, // Force WebSQL; same as using setDriver()
    name: 'docs',
    version: 1.0,
    size: 4980736, // Size of database, in bytes. WebSQL-only for now.
    storeName: 'keyvaluepairs', // Should be alphanumeric, with underscores.
    description: 'docs localStorage description',
});
const webSql: LocalForage = localForage.createInstance({
    driver: localForage.WEBSQL, // Force WebSQL; same as using setDriver()
    name: 'docs',
    version: 1.0,
    size: 4980736, // Size of database, in bytes. WebSQL-only for now.
    storeName: 'keyvaluepairs', // Should be alphanumeric, with underscores.
    description: 'docs localStorage description',
});
const indexDB: LocalForage = localForage.createInstance({
    driver: localForage.INDEXEDDB, // Force WebSQL; same as using setDriver()
    name: 'docs',
    version: 1.0,
    size: 4980736, // Size of database, in bytes. WebSQL-only for now.
    storeName: 'keyvaluepairs', // Should be alphanumeric, with underscores.
    description: 'docs localStorage description',
});
export { localStorage, webSql, indexDB }
开发者ID:snippetmodule,项目名称:docs-search-client,代码行数:27,代码来源:storage.ts


注:本文中的localforage.createInstance函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。