Skip to content

Loading…

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

Open
gregmac opened this Issue · 0 comments

1 participant

@gregmac

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).

@gregmac gregmac added a commit to gregmac/jQuery-store that referenced this issue
@gregmac gregmac Re-initialize encoders and decoders for each instance instead of glob…
…ally (fixes #5)
caac96c
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.