Coder Social home page Coder Social logo

tuax / tua-storage Goto Github PK

View Code? Open in Web Editor NEW
46.0 6.0 8.0 408 KB

📦 统一封装各个端(小程序、web 端、React-Native、Node 端)中对于缓存层的使用(A common storage for web(localStorage), for RN(AsyncStorage), for mini-program(wx) or just memory cache(Node.js))

Home Page: https://tuax.github.io/tua-storage/

License: MIT License

JavaScript 100.00%
storage tua localstorage tua-storage asyncstorage javascript wx wxapp miniprogram

tua-storage's People

Contributors

buptsteve avatar evinma 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

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

tua-storage's Issues

feat: add an online example

你的功能请求是否与某些问题相关?请描述
语言表达太抽象,Talk is cheap, show me the code!

描述您想要的解决方案
借助 codesandbox 搞一个在线 example。

描述你考虑过的备选方案
codepen 和 jsfiddle 也可以搞个

如果存储满了,如何控制内存

Is your feature request related to a problem? Please describe.
A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]

Describe the solution you'd like
A clear and concise description of what you want to happen.

Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.

Additional context
Add any other context or screenshots about the feature request here.

bug: 返回值只有 code 和 data

版本
Version 1.7.0

描述一下 bug
简洁清晰地描述一下 bug。如果方便的话,添加一些截图描述你的问题。

目前由于这个函数只取了 code 和 data 导致接口返回的其他字段被过滤了。

https://github.com/tuateam/tua-storage/blob/02cfd36f36b8408667ff9810965ef327e0320c1d/src/index.js#L510

复现 bug
复现的步骤:

  1. 首先接口返回了除了 code、data 之外的数据,例如 msg。
  2. load 该接口
  3. 取数据时发现 msg 丢了

预期行为
简洁清晰地描述一下预期行为。

返回所有数据

feat: add `syncOptions` options

你的功能请求是否与某些问题相关?请描述
目前版本中对于 syncFn 只能传递一个参数即 syncParams

https://github.com/tuateam/tua-storage/blob/c792086f8509e52be563371ebc49a3853f465a52/src/index.js#L496

但在搭配 tua-api 使用时,没法方便地传递 运行时配置

目前只能自己临时写个 syncFn 函数包一下实现

描述您想要的解决方案
增加一个 syncOptions 参数,这样在调用 syncFn 时即可传递多参数。

  • 类型:any
  • 默认值:[]

syncOptions 类型为数组时,以这样的方式调用。

syncFn(syncParams, ...syncOptions)

即数组的各个元素分别作为 syncFn 的第二个到第 n 个参数。

其他类型时,以这样的方式调用 syncFn(syncParams, syncOptions),即作为第二个参数。

bug: QuotaExceededError The quota has been exceeded.

版本
Version v1.7.2

描述一下 bug
简洁清晰地描述一下 bug。如果方便的话,添加一些截图描述你的问题。

在某些机器或 Safari 的无痕浏览模式中,调用 setItem 时会报错

QuotaExceededError
The quota has been exceeded.

复现 bug
复现的步骤:

  1. 首先开启 Safari 的无痕浏览模式
  2. 看到了错误

预期行为
简洁清晰地描述一下预期行为。

假如在初始化 setItem 时报错,则降级使用内存缓存,并打印出错误。

附加上下文
添加一些问题的相关上下文。

增加 Vue 插件的支持

import Vue from 'vue'
import TuaStorage from 'tua-storage'

Vue.use(TuaStorage, {
    storageEngine: window.localStorage,
    // other options
})
// Foo.vue
export default {
    mounted () {
        this.$tuaStorage.load({ ... })
    },
}

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.