Giter VIP home page Giter VIP logo

Comments (4)

marcuswestin avatar marcuswestin commented on May 22, 2024

Hi @irfancue, I added a test in 3ab2df0 and do not see the issue you're talking about in Chrome 24.0.1312. Can you do some more investigation?

Cheers!
Marcus

from store.js.

irfancue avatar irfancue commented on May 22, 2024

Hi Marcus,

I have different issues:

This works
store.set("user", {id :"1", name: "Joe"});
No problem getting
var userName = store.get("user").name;
console.log(userName); //prints Joe

But when I do not "set" before "get" Javascript throws an error

        var testA = store.get("IHaveNotBeenSetBefore");         
        console.log(testA); // ERROR instead of "undefined"

And if want to change just one value I have first to get the element, then add a new key and then set it again:

                var user = store.get("user");
                user.birthdays = response.birthdays.count //NEW key birthdays
                store.set("user", user);

If I do it like

store.set("user", {name: "Joe", id:1});
store.set("user", {birthdays: response.birthdays.count};

all other keys (name, id) are deleted.

Is there a workaround?

from store.js.

marcuswestin avatar marcuswestin commented on May 22, 2024

What browser are you on? Can you please create a standalone HTML page which replicated your first issue and upload that?

Regarding your second issue, store.js merely serializes and deserializes for you, but you can easily write a function to do what you need. E.g

function addProperties(key, properties) {
store.set(key, jQuery.merge(store.get(key) || {}), properties))
}

-- while mobile

On Feb 14, 2013, at 9:58 AM, irfancue [email protected] wrote:

Hi Marcus,

I have different issues:

This works
store.set("user", {id :"1", name: "Joe"});
No problem getting
var userName = store.get("user").name;
console.log(userName); //prints Joe

But when I do not "set" before "get" Javascript throws an error

    var testA = store.get("IHaveNotBeenSetBefore");         
    console.log(testA); // ERROR instead of "undefined"

And if want to change just one value I have first to get the element, then add a new key and then set it again:

            var user = store.get("user");
            user.birthdays = response.birthdays.count //NEW key birthdays
            store.set("user", user);

If I do it like

store.set("user", {name: "Joe", id:1});
store.set("user", {birthdays: response.birthdays.count};

all other keys (name, id) are deleted.

Is there a workaround?


Reply to this email directly or view it on GitHub.

from store.js.

marcuswestin avatar marcuswestin commented on May 22, 2024

Hi @irfancue,

If you're still seeing an issue please fork and create a failing test in test.html (http://marcuswestin.github.com/store.js/test.html).

Cheers!
Marcus

from store.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.