function readFile (filename, options, callback) { // Options do not matter in browser setup if (typeof options === 'function') { callback = options; } localforage.getItem(filename, function (err, contents) { return callback(null, contents || ''); }); }
localforage.getItem('user_token').then(token => { if (token && !store.state.user_token) { store.commit('USER_TOKEN', token) api .getUser(token) .then(user_info => { console.log(user_info) store.commit('USER_INFO', user_info.data.user) }) .catch(console.error) } })
async initialize () { if (this.storage) { var keys = await this.storage.keys() return Promise.all(keys.map(async key => { this.cache[key] = await this.storage.getItem(key) })) } }
import("localforage").then(localForage => { localForage.getItem(key).then(data => { if (data) { const src = URL.createObjectURL(base64ToBlob(data)) this.setState({ src }) } else if (file && file.constructor !== Object) { const src = URL.createObjectURL(file) this.setState({ src }) } }) })
static async willGetAccessToken() { return localForage.getItem(persist.ACCESS_TOKEN_KEY).catch(err => err) }
function rename (filename, newFilename, callback) { localforage.getItem(filename, function (err, value) { if (value === null) { localforage.removeItem(newFilename, function () { return callback(); }); } else { localforage.setItem(newFilename, value, function () { localforage.removeItem(filename, function () { return callback(); }); }); } }); }
function appendFile (filename, toAppend, options, callback) { // Options do not matter in browser setup if (typeof options === 'function') { callback = options; } localforage.getItem(filename, function (err, contents) { contents = contents || ''; contents += toAppend; localforage.setItem(filename, contents, function () { return callback(); }); }); }
static async willGetSessionToken() { return localForage.getItem(persist.SESSION_TOKEN_KEY).catch(err => err) }
function exists (filename, callback) { localforage.getItem(filename, function (err, value) { if (value !== null) { // Even if value is undefined, localforage returns null return callback(true); } else { return callback(false); } }); }
function readFile (filename, options, callback) { // Options do not matter in browser setup if (typeof options === 'function') { callback = options; } localforage.getItem(filename, function (err, contents) { return callback(null, contents || ''); }); }
function appendFile (filename, toAppend, options, callback) { // Options do not matter in browser setup if (typeof options === 'function') { callback = options; } localforage.getItem(filename, function (err, contents) { contents = contents || ''; contents += toAppend; localforage.setItem(filename, contents, function () { return callback(); }); }); }
function exists (filename, callback) { localforage.getItem(filename, function (err, value) { if (value !== null) { // Even if value is undefined, localforage returns null return callback(true); } else { return callback(false); } }); }
function rename (filename, newFilename, callback) { localforage.getItem(filename, function (err, value) { if (value === null) { localforage.removeItem(newFilename, function () { return callback(); }); } else { localforage.setItem(newFilename, value, function () { localforage.removeItem(filename, function () { return callback(); }); }); } }); }