本文整理汇总了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));
}
示例2: constructor
constructor(params?: Partial<LocalBackendClient>) {
super(params);
this.client = LocalForage.createInstance({
driver: LocalForage.INDEXEDDB,
name: 'scripsi'
});
}
示例3: constructor
constructor() {
if (!Storage.INSTANCE && !Config.isServer) {
this.storage = localforage.createInstance({
name: 'storage',
});
this.storage.setItem('timestamp', new Date());
}
Storage.INSTANCE = this;
}
示例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]) {
示例5:
LocalForage.defineDriver(CordovaSQLiteDriver).then(() => {
db = LocalForage.createInstance(config);
})
示例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'));
}
});
示例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])
}
}
示例8:
LocalForage.defineDriver(CordovaSQLiteDriver).then(() => {
this.db = LocalForage.createInstance({
name: this.config.get('storage.name')
});
}).then(() => {
示例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 }