JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 13
  • Score
    100M100P100Q32840F
  • License MIT

A very simplistic approach to observe on Object.

Package Exports

  • observa

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (observa) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Observa

Very simple library to observe for changes in JavaScript object. Observa utilizes es2015 proxy feature to detect any change in Object. For browsers which do not support Proxy, Observa will dirty-check Object to identify change.

How to use

  • Install using npm
    npm install observa
  • Import in your project
    import Observa from "observa";
  • Create object which can be observed
    var person = Observa({
        name: {
            firstName: "John",
            lastName: "Doe"
        },
        age: 29
    })
    
    // To listen for change
    person.onChange = function (updatedObject, targetObject, keyName, valueSet) {
        // Your change listener functionality
    }

Alternatively, you can also include script file in your html as:

    <script src="//unpkg.com/observa/dist/observa.min.js"></script>

This will add Observa over the global context. Which can be ued as

    var person = Observa.default({
        name: {
            firstName: "John",
            lastName: "Doe"
        },
        age: 29
    })
    
    // To listen for change
    person.onChange = function (updatedObject, targetObject, keyName, valueSet) {
        // Your change listener functionality
    }