Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/foxbunny/observable
Simple lightweight observable values
https://github.com/foxbunny/observable
Last synced: 27 days ago
JSON representation
Simple lightweight observable values
- Host: GitHub
- URL: https://github.com/foxbunny/observable
- Owner: foxbunny
- License: other
- Created: 2013-09-27T08:02:50.000Z (about 11 years ago)
- Default Branch: master
- Last Pushed: 2013-09-27T08:41:07.000Z (about 11 years ago)
- Last Synced: 2023-03-10T22:13:40.394Z (almost 2 years ago)
- Language: CoffeeScript
- Size: 105 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.mkd
- Changelog: CHANGES.mkd
- License: LICENSE
Awesome Lists containing this project
README
# Observable values for JavaScript
This library provides a simplistic support for observable values (and thus
means for performing data-binding).This code has not been tested yet. There are probably bugs in it.
## Motivation
Althought many frameworks provide the same functionality in many different
forms, they are usually fully-featured and not very lightweight. Using them may
imply pulling in most or all of the framework as well (e.g., BackboneJS). Even
if you are already using such a framework, you may still have situation where
you need data-binding without everything else that usually comes with it.The `Observable` constructor fulfills this role.
## Installation
### NodeJS
This module is currently not published on NPM. You can install it from a
directory containing the source code, or you can simply copy the
`observable.js` file into your project.### Browsers
You can use this module either stand-alone using `` tags, or you can
use it as an AMD loader with a compatible module loader such as RequireJS.### volo
You can install this module with volo normally:
volo add foxbunny/observable
## Basic usage
var observable = new Observable(12);
var observer = function (newVal, oldVal) {
console.log(oldVal + '->' + newVal);
}
observable.watch(observer)
observable.set(9) // logs "12 -> 9"
observable.set(9) // doesn't do anything because it's the same value
observable.get() // returns 9