Skip to content
GitLab
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
    • Contribute to GitLab
  • Sign in / Register
  • A angular-storage
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • Auth0
  • angular-storage
  • Merge requests
  • !5

Implement namespacing (issue #2)

  • Review changes

  • Download
  • Email patches
  • Plain diff
Closed Administrator requested to merge github/fork/thomastuts/thomastuts/namespaces into master Oct 08, 2014
  • Overview 4
  • Commits 2
  • Pipelines 0
  • Changes 2

Created by: thomastuts

I've implemented namespacing since I needed it for my current project, and because there was an issue for it already anyway (see #2 (closed)). I've added a couple of tests that all pass. It supports the following functionality:

  • Adding a namespace
  • Adding an optional namespace delimiter (defaults to .)
  • Specifying either a custom namespace or no namespace on a per-method basis (i.e. get(), set() and remove()). If the namespace is null, it will not use any namespace to get/set/remove that value (similar to the current implementation). If the namespace is given and not null, it will use that namespace to perform the operation. I'm not sure about the syntax yet, since I didn't want to change too much of the original API.

Also: you might notice that I have replaced all references to this with a top-level store object, this way we can reference it in the helper function that creates the namespaced key.


Namespacing configuration

I didn't want to create a whole new provider just to be able to configure things in Angular's config() block so I've declared the configuration on the service instead. There are two namespacing options you can set:

  • store.namespace which defaults to null (current behaviour)
  • store.namespaceDelimiter which defaults to . - this will result in stored keys such as namespace.key

Custom/no namespacing syntax

In the store methods, the namespace parameter can either be omitted (default behaviour), null where it will not use any namespace, or a value which will be used for the namespace instead of the default one.

  • store.get(name, namespace)
  • store.remove(name, namespace)
  • store.set(name, elem, namespace) -- This is the syntax I'm not sure about since the other two methods have the custom namespace right after the key name. I think this way is better though, since this behaviour most likely won't be used a lot, and if we moved it to the second argument, people would have to type store.set('someName', null, 'someValue') all the time. Would love to hear your feedback on this.
Assignee
Assign to
Reviewers
Request review from
Time tracking
Source branch: github/fork/thomastuts/thomastuts/namespaces