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

    ...

}


Points of Interest

Partial Application

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

Undocumented Service

$browser

Questions?

ngStorage

By G. Kay Lee

ngStorage

A 10-minute talk on ngStorage, a Web Storage module for AngularJS with a minimalist API design. (https://github.com/gsklee/ngStorage)

  • 13,334