GithubHelp home page GithubHelp logo

force storage document about basil.js HOT 4 CLOSED

bitinn avatar bitinn commented on May 12, 2024
force storage document

from basil.js.

Comments (4)

johnhaldson avatar johnhaldson commented on May 12, 2024

Isn't the defaultStorage set on init if passed in the options and then used by default?

https://github.com/Wisembly/basil.js/blob/master/src/basil.js#L189

from basil.js.

bitinn avatar bitinn commented on May 12, 2024

yes, but if you try to overwrite the default with example query, i don't think you will get the desired result.

var storages = _toStoragesArray(options.storages) || [this.defaultStorage];

set does not use options.storage, only options.storages; and the way options.storages are used seem undesirable.

from basil.js.

guillaumepotier avatar guillaumepotier commented on May 12, 2024

Indeed, we deprecated options.storage and implemented instead options.storages to allow storing on the go on one or more storages at the time.

If you want to persist on cookie instead of default local, just use

basil.set('foo', 'bar', { 'storages': ['cookie'] });

If you want to persist both in cookie and localstorage, use then

basil.set('foo', 'bar', { 'storages': ['local', 'cookie'] });

We changed a bit the API because we faced in our project the need to store something in localstorage which is fast for our app, but needed to persist it too in cookie for later usage.

I don't really see why the ability to set and remove on all available storage is an undesirable feature?

from basil.js.

guillaumepotier avatar guillaumepotier commented on May 12, 2024

Hi there,

We are nearly ready to roll out #26 0.4.0 version, that changed the actual behavior. Basil won't allow anymore to persist in simultaneous storages, but will choose the 1rst available storage in list if given in storages options

// try first to store it into cookies and if not possible into localStorage
basil.set('foo', 'quux', { 'storages': ['cookie', 'local'] });

It would still be possible to directly store in a specific storage using Basil.localStorage.set() API.

Best

from basil.js.

Related Issues (20)

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.