Giter Site home page Giter Site logo

contolini / observe-shim Goto Github PK

View Code? Open in Web Editor NEW

This project forked from iobeya/observe-shim

0.0 1.0 0.0 373 KB

A shim for the Object.observe Harmony Proposal (see : http://wiki.ecmascript.org/doku.php?id=harmony:observe).

License: Apache License 2.0

observe-shim's Introduction

Object.observe shim

See : The harmony proposal page.

Goal:

This shim provides an implementation of the algorithms described in the harmony proposal, and is intended to work on all ES5-compliant browsers.

Dependencies :

While this implementation does not have dependencies, it tries to use "setImmediate" if present, and fall back on setTimeout if it is not, it is recommended to use a setImmediate shim for browsers that do not support it natively. ( A good one can be found here )

Limitations :

While this shim provides an implementation for the Object methods, and the Notifier prototype described in the proposal, it does not try to catch and notify by any means changes made to an object. Instead it let you call manually the notify method :

Object.getNotifier(myObject).notify({ type : "updated" , ....});

ObserveUtils :

The 'observe-utils.js' utilities that facilitate the use of this shim can be found on his own repository

Usage :

This shim does not try to detect the Object.observe feature presence, instead it leaves you the charge to detected it, and to conditionally load this shim, using the feature detection library of your choice.

Example :

var myObject = {};
ObserveUtils.defineObservableProperties(myObject, "foo", "bar");
Object.observe(myObject, function (changes) {
    console.log(changes);
});
myObject.foo = "Hello";
myObject.bar = "World";

//log

[
    {
        name : "foo",
        object : myObject,
        oldValue : undefined,
        type : "updated"
    },
    {
        name : "bar",
        object : myObject,
        oldValue : undefined,
        type : "updated"
    }
]

Build And Test:

Require bower and grunt-cli installed on your machine.

npm install & bower install
grunt // test and build
grunt test // test only

observe-shim's People

Contributors

fdecampredon avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.