Initializing $.store twice adds duplicate en/decoders #5

gregmac opened this Issue Jul 12, 2012 · 0 comments


None yet
1 participant

gregmac commented Jul 12, 2012

Running the following code:

s = new $.store(); 
s.set('test', {"a":1}); 
console.log('Get 1', s.get('test')); 
s = new $.store(); 
console.log('Get 2', s.get('test')); 

results in

Get 1  Object
              a: 1
SyntaxError: Unexpected token o

This happens because .encoders and .decoders are part of the prototype, and thus globally modified every time new $.store is called.

This is an issue because I am using this in a single page application, and use it in just one model where it's needed (instead of storing a global reference and only initializing once).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment