storeit-value
Provides a simple interface to read/write and observe changes to a storeit
value.
Where storeit
exposes an api to manage all values stored,
storeit-value
provides access to a single value.
Less talk more rock...
// Create a `storeit` store with the super sweet `storeit-webstorage` package. var Storeit = StoreitLocal; // use an HTML5 local storage provider.var StoreitValue = ; var todoStore = "todos"; var laundryTodo = todoStore id: 1 title: "Laundry" isDone: false; // The key used by the store is exposed as a getter.var key = laundryTodokey; // `storeit` defaults this to `id` property. // Get a property.var isDone = laundryTodo; // Check for a propertyvar hasTitle = laundDryTodo; // Set a property.laundryTodo; // Auto saved into storage. // Set a few properties.laundryTodo; // Both are saved! // Listen for changes. { console; // From the above set would output `{title: "Do the Laundry.", isDone: true }`} laundryTodo;laundryTodo;
In addition, you can extend StoreitValue with custom types!
// Returns a function constructor, cool!var TodoValue = StoreitValue; var laundryTodo = id: 1 title: "Laundry" isDone: false ; // `laundryTodo` is an instanceof StoreitValue, so it exposes the same api:// `get/set`, `on/off` // In addition... getters and setters! laundryTodoisDone = true;console;
Githooks
For developers contributing to this repo's source code, please run the following npm script:
npm run githooks
This script provides:
- pre commit: Runs jshint before commit is added to history.
- pre push: Runs tests before code is pushed up to remote.