Skip to content

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

Open
@gregmac

Description

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions