ngStorage

Gias Kay Lee

@gsklee / gsklee.im

Such is true for APIs as well

People ♥ elegant things

http://www.pptbackgrounds.net/elegant-grey-illumination-background-presentations-backgrounds.html

Backbone

var nothing = new (Backbone.Collection.extend({

    model: Backbone.Model

}))();



Angular

$scope.nothing = [];

Apparently far more elegant

An elegant API should feel

natural & terse

That's why I decided to roll my own solution...


...despite of many existing solutions

ngStorage

$localStorage & $sessionStorage Done Right

https://github.com/gsklee/ngStorage

Usage


angular.module('app', [

    'ngStorage'

]).controller('Ctrl', function(

    $scope,

    $localStorage

){

    $scope.$storage = $localStorage;

});

API Design


$localStorage / $sessionStorage


{

    $default: function

    $reset: function

    ...

}


Read 'n' Write
Delete
Delete Everything
Permitted Values

Demos

Points of Interest

Partial Application

factory('$sessionStorage', _storageFactory('sessionStorage'));

Undocumented Service

$browser

Questions?