question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Handle namespace

See original GitHub issue

Hi,

It would be nice to be able to set a namespace when using store.js, because if you use store on your website and do a store.clear(), it clear all the localStorage and you can probably impact other websites that are using localStorage too.

It could be something like :

store.set('username', 'marcus') // 'username' => 'marcus'
store.get('username') // 'marcus'
store.clear() // clear ALL the localStorage

store.namespace('myNameSpace'); 

store.set('username', 'john') // 'myNameSpace.username' => 'john'
store.get('username') // 'john'
store.clear() // clear all myNameSpace keys in localStorage

Issue Analytics

  • State:closed
  • Created 8 years ago
  • Comments:10 (4 by maintainers)

github_iconTop GitHub Comments

2reactions
marcuswestincommented, Feb 28, 2017

Store.js v2.0 has been released with support for namespaces!

var ns1 = store.namespace('ns1')
var ns2 = store.namespace('ns2')
ns1.set('foo', 'bar1')
ns2.set('foo', 'bar2')
ns1.get('foo') == 'bar1'
ns2.get('foo') == 'bar2'

One of the plugins uses it to store expiration timestamps: https://github.com/marcuswestin/store.js/blob/master/plugins/expire.js

If you update to the latest version you will automatically get this functionality plus a bunch more 😃

0reactions
marcuswestincommented, Dec 27, 2016

Namespaces are now implemented in version 2. Stay tuned for a release in the new year, or get the release candidate at https://github.com/marcuswestin/store.js/tree/v2-dev?files=1

Read more comments on GitHub >

github_iconTop Results From Across the Web

Namespaces - Kubernetes
In Kubernetes, namespaces provides a mechanism for isolating groups of resources within a single cluster. Names of resources need to be unique ...
Read more >
How to handle namespaces in C++? - Stack Overflow
So in your case, you need to close the namespaces where the forward declaration is. namespace com { namespace example { namespace mydialogs ......
Read more >
namespaces(7) - Linux manual page - man7.org
A namespace wraps a global system resource in an abstraction that makes it ... file handle for the corresponding namespace of the process...
Read more >
RFC 3651: Handle System Namespace and Service Definition
The namespace definition specifies the handle syntax and its semantic ... RFC 3651 Handle System Service Definition November 2003 Table of Contents 1....
Read more >
Configure namespaces and namespace-scoped objects
This page illustrates how to use Config Sync to manage namespaces and namespace-scoped objects. Configure a namespace. Configuring a namespace functions ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found