Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

watch-me-now

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

watch-me-now

Wrap an object (such as application state or data model) to listen for changes!

  • 1.0.5
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Watch Me Now

the teeny-tiny, zero-dependency object observer

  • emits on property assignments for all data types
  • emits on delete
  • emits on mutable Array function calls
  • works on nested properties (infinitely)
  • works in node as well as the browser!
installation:

npm install watch-me-now --save

example usage:
const WatchMeNow = require(`watch-me-now`)

// define a callback for when changes occur
const onStateChange = ({type, current, old, path, key}) => {
    console.log(`\nonStateChange() - ${type}, ${path.length ? `path: ${path}, ` : ``}key: ${key}`)
    console.log({new_state: JSON.stringify(current)})
    console.log({old_state: JSON.stringify(old)})
}

// instantiate an object to observe
const state = WatchMeNow({}, onStateChange)

// go nuts
state.foo = `bar`
state.foo = {bar: `baz`}
state.foo.bar = `bum`

state.foo.bar = 24601
state.foo.bar += 5 + 14

delete state.foo.bar

state.my_array = [1, 2, 3, 4, 5]
state.my_array[0] = `potato`
state.my_array.reverse()

state.foo = {nested_array: [`a`, `b`, `c`]}
state.foo.nested_array.reverse()
state.foo.nested_array.push({six_times_seven: 42})

Keywords

FAQs

Package last updated on 03 Jun 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc