treble-hook
Advanced tools
Comparing version 0.0.19 to 0.0.20
@@ -28,5 +28,18 @@ "use strict"; | ||
if (topicRecord) { | ||
Object.values(topicRecord.subscriptionMap).forEach(publicHook => publicHook[TupleIndex.Publish](newState)); | ||
topicRecord.currentState = newState; | ||
topicRecord.hasBeenPublished = true; | ||
const allowDupeState = false; | ||
const suppressDupeStateWarning = false; | ||
let proceed = true; | ||
if (!allowDupeState) { | ||
const currentStateCompare = JSON.stringify(topicRecord.currentState); | ||
const newStateCompare = JSON.stringify(newState); | ||
proceed = newStateCompare !== currentStateCompare; | ||
} | ||
if (proceed) { | ||
Object.values(topicRecord.subscriptionMap).forEach(publicHook => publicHook[TupleIndex.Publish](newState)); | ||
topicRecord.currentState = newState; | ||
topicRecord.hasBeenPublished = true; | ||
} | ||
else if (!suppressDupeStateWarning) { | ||
console.warn('[treble-hook] A publish of unchanged state was attempted for topic:', topic, '\n\nIf this is desired behavior then set the allowDupeState flag to true in treble-hook config.'); | ||
} | ||
} | ||
@@ -33,0 +46,0 @@ else { |
{ | ||
"name": "treble-hook", | ||
"version": "0.0.19", | ||
"version": "0.0.20", | ||
"description": "Get hooked on simple subscribe-and-publish in ReactJS.", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
17615
103