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

dispatchr

Package Overview
Dependencies
Maintainers
5
Versions
40
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dispatchr - npm Package Compare versions

Comparing version 0.2.10 to 0.2.11

8

lib/Dispatcher.js

@@ -186,3 +186,4 @@ /**

* Returns a raw data object representation of the current state of the
* dispatcher and all store instances
* dispatcher and all store instances. If the store implements a shouldDehdyrate
* function, then it will be called and only dehydrate if the method returns `true`
* @method dehydrate

@@ -196,5 +197,6 @@ * @returns {Object} dehydrated dispatcher data

var store = self.storeInstances[storeName];
if (store.dehydrate) {
stores[storeName] = store.dehydrate();
if (!store.dehydrate || (store.shouldDehydrate && !store.shouldDehydrate())) {
return;
}
stores[storeName] = store.dehydrate();
});

@@ -201,0 +203,0 @@ return {

{
"name": "dispatchr",
"version": "0.2.10",
"version": "0.2.11",
"description": "A Flux dispatcher for applications that run on the server and the client.",

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

@@ -175,5 +175,15 @@ # Dispatchr

### shouldDehydrate()
The store can optionally define this function to control whether the store state should be dehydrated by the dispatcher. This method should return a boolean. If this function is undefined, the store will always be dehydrated (just as if true was returned from method).
```js
ExampleStore.prototype.shouldDehydrate = function () {
return true;
}
```
## Helper Utilities
These utilities make creating stores less verbose and provide some `change` related functions that are common amongst all store implementations.
These utilities make creating stores less verbose and provide some `change` related functions that are common amongst all store implementations. These store helpers also implement a basic `shouldDehydrate` function that returns true if `emitChange` has been called by the store and false otherwise.

@@ -180,0 +190,0 @@ ### BaseStore

@@ -19,2 +19,3 @@ /**

this.dispatcher = dispatcher;
this._hasChanged = false;
if (this.initialize) {

@@ -33,6 +34,15 @@ this.initialize();

BaseStore.prototype.getContext = function getContext() {
return this.dispatcher.getContext();
return this.dispatcher.getContext();
};
/**
* Convenience method for getting the store context object.
* @method getContext
* @return {Object} Returns the store context object.
*/
BaseStore.prototype.getContext = function getContext() {
return this.dispatcher.getContext();
};
/**
* Add a listener for the change event

@@ -43,3 +53,3 @@ * @method addChangeListener

BaseStore.prototype.addChangeListener = function addChangeListener(callback) {
this.on(CHANGE_EVENT, callback);
this.on(CHANGE_EVENT, callback);
};

@@ -53,6 +63,17 @@

BaseStore.prototype.removeChangeListener = function removeChangeListener(callback) {
this.removeListener(CHANGE_EVENT, callback);
this.removeListener(CHANGE_EVENT, callback);
};
/**
* Determines whether the store should dehydrate or not. By default, only dehydrates
* if the store has emitted an update event. If no update has been emitted, it is assumed
* that the store is in its default state and therefore does not need to dehydrate.
* @method shouldDehydrate
* @returns {boolean}
*/
BaseStore.prototype.shouldDehydrate = function shouldDehydrate() {
return this._hasChanged;
};
/**
* Emit a change event

@@ -63,5 +84,6 @@ * @method emitChange

BaseStore.prototype.emitChange = function emitChange(param) {
this.emit(CHANGE_EVENT, param || this);
this._hasChanged = true;
this.emit(CHANGE_EVENT, param || this);
};
module.exports = BaseStore;

@@ -30,7 +30,6 @@ /**

} else {
if (!dest[prop]) {
dest[prop] = src[prop];
} else {
if (dest.hasOwnProperty(prop)) {
throw new Error('Mixin property collision for property "' + prop + '"');
}
dest[prop] = src[prop];
}

@@ -37,0 +36,0 @@ });

Sorry, the diff of this file is not supported yet

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