0.5.0 • Published 9 years ago

angular2-locker v0.5.0

Weekly downloads
4
License
MIT
Repository
github
Last release
9 years ago

angular2-locker

Build Status Code Climate

Wrapper around sessionStorage and localStorage for angular2. If both are unavailable will use an in memory storage.

Getting Started

$ npm i --save angular2-locker
import {NgModule} from '@angular/core'
import {LockerModule, Locker, LockerConfig} from 'angular2-locker'

@Component({
  selector: 'app',
  template: `...`
})
class App {
  constructor(locker: Locker) {
    locker.set('something', value)
  }
}

@NgModule({
  providers: [LockerModule],
  declarations: [App],
  bootstrap: [App]
})
class AppModule {
  constructor(private locker: Locker) {}
}

With Custom Config

import {LockerModule, LockerConfig, DRIVERS} from 'angular2-locker'

const lockerConfig = new LockerConfig('nameSpace', DRIVERS.MEMORY, '-')

@NgModule({
  providers: [LockModule.forRoot(lockerConfig)]
  ...
})
class SomeModule {

}

Methods

####get locker.get('myKey')

####set

locker.set('myKey', 'value')
locker.set('myKey', {object: 'value'})

####key

locker.set('key', 'value')

locker.key(0) // 'key'

####has locker.has('key')

####setNamespace locker.setNamespace('myName') locker.setNamespace() - Resets to lockerConfig default

####setSeparator locker.setSeparator('-') locker.setSeparator() - Resets to lockerConfig default

####useDriver

// for more info on drivers look for static methods
var driver = locker.useDriver(Locker.DRIVERS.LOCAL)

driver.set('keey', 'value')

####remove locker.remove('key')

####clear locker.clear()

Static Methods

DRIVERS

These are the types of drivers available. If you try to set it to a driver that is unsupported it will fallback to the memory driver Types are available under Locker.DRIVERS or import {DRIVERS} from 'angular2-locker'

  • DRIVERS.SESSION - Session Cache
  • DRIVERS.LOCAL - Local Storage
  • DRIVERS.MEMORY - Memory Storage
  • DRIVERS.COOKIE - Cookies
0.5.0

9 years ago

0.4.1

9 years ago

0.4.0

9 years ago

0.3.1

9 years ago

0.3.0

9 years ago

0.2.7

9 years ago

0.2.6

9 years ago

0.2.5

9 years ago

0.2.4

9 years ago

0.2.3

9 years ago

0.2.2

9 years ago

0.2.1

9 years ago

0.2.0

9 years ago

0.1.8

9 years ago

0.1.7

10 years ago

0.1.6

10 years ago

0.1.5

10 years ago

0.1.4

10 years ago

0.1.3

10 years ago

0.1.2

10 years ago

0.1.1

10 years ago

0.1.0

10 years ago