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

redux-watch

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redux-watch - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

4

CHANGELOG.md

@@ -0,3 +1,7 @@

2015-12-14 / 1.1.0
------------------
- pass `objectPath` to watch callback (access in `subscribe()`)
2015-12-14 / 1.0.0
------------------
- initial release

2

index.js

@@ -14,3 +14,3 @@ var getValue = require('object-path').get

if (compare(baseVal, newVal)) return
fn(newVal, baseVal)
fn(newVal, baseVal, objectPath)
baseVal = newVal

@@ -17,0 +17,0 @@ }

{
"name": "redux-watch",
"version": "1.0.0",
"version": "1.1.0",
"description": "Watch Redux state for changes.",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -43,13 +43,17 @@ redux-watch

```js
// ... other imports requires
// ...
// ... other imports/requires
import watch from 'redux-watch'
// assuming you have an admin reducer / state slice
console.log(store.getState().admin.name) // 'JP'
// store is THE redux store
// assuming you have an admin reducer
let w = watch(store.getState, 'admin.name')
store.subscribe(w(function(newVal, oldVal) {
console.log(newval)
console.log(oldVal)
store.subscribe(w((newVal, oldVal, objectPath) => {
console.log('%s changed from %s to %s', objectPath, oldVal, newVal)
// admin.name changed from JP to JOE
}))
// somewhere else, admin reducer handles ADMIN_UPDATE
store.dispatch({ type: 'ADMIN_UPDATE', payload: { name: 'JOE' }})
```

@@ -64,3 +68,2 @@

// ... other imports requires
// ...
import watch from 'redux-watch'

@@ -70,3 +73,3 @@

let w = watch(() => mySelector(store.getState()))
store.subscribe(w(function(newVal, oldVal) {
store.subscribe(w((newVal, oldVal) => {
console.log(newval)

@@ -73,0 +76,0 @@ console.log(oldVal)

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