當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。