Giter Club home page Giter Club logo

vlf's Introduction

vlf

vue-localforage and support typescript

localForage is a fast and simple storage library for JavaScript. localForage improves the offline experience of your web app by using asynchronous storage (IndexedDB or WebSQL) with a simple, localStorage-like API.

localForage uses localStorage in browsers with no IndexedDB or WebSQL support. See [the wiki for detailed compatibility info][supported browsers].

Install

npm install  --save localforage vlf

How to use vlf

import Vlf from 'vlf'
import localforage from 'localforage'
Vue.use(Vlf, localforage)

In your code

// 创建实例
this.$vlf.createInstance({
    storeName: 'user'
})
// 迭代
this.$vlf.iterate((value, key, num) => {
    console.log(key);
});
// 设置值
this.$vlf.setItem('test', 'hello').then(v => {
    console.log(v);
});

// ...和官方调用一致
// The other methods of use are the same as the official website, just add a this.$vlf in front, the same behind!

vlf's People

Contributors

dedayoa avatar dmlzj avatar vlaim avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

vlf's Issues

过度封装?

例如:

getItem (key) {
    return new Promise((resolve, reject) => {
       localForage.getItem(key).then((value) => {
           resolve(value)
      }).catch((err) => {
           reject(err)
    })
  })
}

// 看过了官网文档,所有的操作都是默认返回一个promise的,所以没必要再封装多一层promise,除非你在它里面处理了某些处理,个人建议还是直接返回就可以了

getItem (key) {
    return localForage.getItem(key)
}

this.$vlf undefined

Trying to install with: yarn add vlf

and using it in the main.ts but it is always {} and in the component this.$vlf returns undefined.

Using it with Vuex

Hi, its possible to use this inside of my store with vuex? the code on the readme only shows how to implement in individual componets but how is the procedure for integrating with vuex?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.