NathanaelA/nativescript-localstorage

setItem writes multiple keys at once

AdamDenoon opened this issue · 1 comments

I write two values into two different keys:

ls.setItem("Foo", "Bar");
ls.setItem("123", "Zar");

This is the result:

Stored Keys:  2 
(0) 123: Zar
(1) Foo: Bar

I then write a new value to a new key:

ls.setItem("456", "Tar");

The result is:

Stored Keys: 3
(0) 123: Tar
(1) 456: Tar
(2) Foo: Bar

The value of Key 0 has been overwritten by the value of Key 1 (which is the newest key). This should not happen.

Disregard... turns out I was saving an Observable object to two different keys, and when I changed the Observable object, it changed under both keys. Not a bug at all! In fact, I think this functionality could be useful ^_^