Git Product home page Git Product logo

Comments (3)

nbubna avatar nbubna commented on September 24, 2024

Interesting. Do you expect this would affect all areas? So store.session.isFake() would return true after calling store.forceFake()? And would you be able to turn off fake mode w/o reloading the page? Like store.forceFake(false)?

My inclination would be no, only have it affect the current area. In fact, the easiest way to implement it would be to replace the area it was called on with a fake one, of course, that's not as trivial to reverse, so i'd probably just have it be forceFake() with no args, unless there was call for turning it off again.

You could probably mimic what i'm picturing by with an extension like:

store._.fn('forceFake', function() {
this._area = _.storage('fake');// uses an internal prop '_area'
})

Then you could call

store.session.forceFake()

And only sessionStorage would be superseded with fake storage.

I haven't tested that, but i think it'd do the trick.

I think this is small enough to be worth considering adding in the next release. Leave this issue open until i do that or change my mind. :)

from store.

TrevorBurnham avatar TrevorBurnham commented on September 24, 2024

Aha, that works! Slightly modified for posterity:

// Register forceFake extension
store._.fn('forceFake', function() {
  this._area = store._.storage('fake');
});

// Force fake localStorage
store.local.forceFake();

// Force fake sessionStorage
store.session.forceFake();

Thanks for your help. 👍

from store.

TrevorBurnham avatar TrevorBurnham commented on September 24, 2024

Reopening re:

I think this is small enough to be worth considering adding in the next release. Leave this issue open until i do that or change my mind. :)

from store.

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.