Comparing version 1.0.1 to 1.1.0
'use strict'; | ||
Object.defineProperty(exports, "__esModule", { | ||
value: true | ||
value: true | ||
}); | ||
@@ -21,43 +21,55 @@ exports.connect = exports.getLastState = exports.getStore = exports.updateStore = exports.createStore = undefined; | ||
var noop = function noop() { | ||
return void 0; | ||
return void 0; | ||
}; | ||
var createStore = exports.createStore = function createStore(initialState) { | ||
return stateSubject.onNext(_extends({}, initialState)); | ||
return stateSubject.onNext(_extends({}, initialState)); | ||
}; | ||
var updateStore = exports.updateStore = function updateStore(newState) { | ||
return stateSubject.onNext(_extends({}, stateSubject.value, newState)); | ||
return stateSubject.onNext(_extends({}, stateSubject.value, newState)); | ||
}; | ||
var getStore = exports.getStore = function getStore() { | ||
return stateSubject; | ||
return stateSubject; | ||
}; | ||
var getLastState = exports.getLastState = function getLastState() { | ||
return stateSubject.value; | ||
return stateSubject.value; | ||
}; | ||
var connect = exports.connect = function connect() { | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
for (var _len = arguments.length, args = Array(_len), _key = 0; _key < _len; _key++) { | ||
args[_key] = arguments[_key]; | ||
} | ||
return function (target) { | ||
var obj = Object.create(target.prototype); | ||
var willMount = obj.componentWillMount; | ||
return function (target) { | ||
var obj = Object.create(target.prototype); | ||
var willMount = obj.componentWillMount; | ||
var willUnmount = obj.componentWillUnmount; | ||
target.prototype.componentWillMount = function () { | ||
var _this = this; | ||
target.prototype.componentWillMount = function () { | ||
var _this = this; | ||
stateSubject.filter(function (state) { | ||
return (0, _lodash.isEqual)(state, getLastState()); | ||
}).map(function (state) { | ||
return args.length ? (0, _lodash.pick)(state, args) : state; | ||
}).subscribe(function (state) { | ||
return _this.setState(state); | ||
}); | ||
this.stateListener = stateSubject; | ||
willMount ? willMount.call(this) : noop(); | ||
}; | ||
this.stateListener.map(function (state) { | ||
return args.length ? (0, _lodash.pick)(state, args) : state; | ||
}).subscribe(function (state) { | ||
return _this.setState(state); | ||
}); | ||
return target; | ||
willMount ? willMount.call(this) : noop(); | ||
}; | ||
target.prototype.componentWillUnmount = function () { | ||
try { | ||
// unsubscribe | ||
this.stateListener.dispose(); | ||
} catch (e) { | ||
// listener has already been removed or component is not mounted any more | ||
} | ||
willUnmount ? willUnmount.call(this) : noop(); | ||
}; | ||
return target; | ||
}; | ||
}; |
{ | ||
"name": "dugong", | ||
"version": "1.0.1", | ||
"version": "1.1.0", | ||
"description": "Minimal State Container for React Apps using RxJS", | ||
@@ -20,3 +20,3 @@ "scripts": { | ||
"type": "git", | ||
"url": "git+https://github.com/AvraamMavridis/Dugong.git" | ||
"url": "git+https://github.com/AvraamMavridis/dugong.git" | ||
}, | ||
@@ -36,7 +36,7 @@ "keywords": [ | ||
"bugs": { | ||
"url": "https://github.com/AvraamMavridis/Dugong/issues" | ||
"url": "https://github.com/AvraamMavridis/dugong/issues" | ||
}, | ||
"homepage": "https://github.com/AvraamMavridis/Dugong#readme", | ||
"homepage": "https://github.com/AvraamMavridis/dugong#readme", | ||
"peerDependencies": { | ||
"react": "^0.14.7", | ||
"react": "^15.0.1", | ||
"rx": "=4.0.0", | ||
@@ -48,2 +48,3 @@ "lodash": "^4.6.1" | ||
"babel-core": "^6.6.4", | ||
"babel-eslint": "^6.0.2", | ||
"babel-plugin-syntax-object-rest-spread": "^6.3.13", | ||
@@ -63,8 +64,8 @@ "babel-plugin-transform-decorators": "^6.4.0", | ||
"eslint": "^2.0.0", | ||
"eslint-config-airbnb": "^6.0.2", | ||
"eslint-config-airbnb": "^7.0.0", | ||
"eslint-plugin-react": "^4.1.0", | ||
"mocha": "^2.4.5", | ||
"promise": "^7.1.1", | ||
"react-addons-test-utils": "^0.14.7", | ||
"react-dom": "^0.14.7", | ||
"react-addons-test-utils": "^15.0.1", | ||
"react-dom": "^15.0.1", | ||
"sinon": "^1.17.3", | ||
@@ -71,0 +72,0 @@ "sinon-chai": "^2.8.0" |
@@ -1,2 +0,2 @@ | ||
# Dugong | ||
# Dugong (Work in progress) | ||
Minimal State Container for React Apps using RxJS | ||
@@ -7,4 +7,7 @@ | ||
![Dugong](https://haydensanimalfacts.files.wordpress.com/2014/12/dugong.jpg) | ||
[![npm version](https://badge.fury.io/js/dugong.svg)](https://badge.fury.io/js/dugong) | ||
[![Build Status](https://travis-ci.org/AvraamMavridis/Dugong.svg?branch=master)](https://travis-ci.org/AvraamMavridis/Dugong) | ||
[![Build Status](https://travis-ci.org/AvraamMavridis/dugong.svg?branch=master)](https://travis-ci.org/AvraamMavridis/dugong) | ||
[![CocoaPods](https://img.shields.io/cocoapods/l/AFNetworking.svg)]() | ||
@@ -123,2 +126,3 @@ [![semantic-versioning](https://img.shields.io/badge/semantic%20-versioning-green.svg)]() | ||
E-mail : avr.mav@gmail.com | ||
Twitter: [@avraamakis](https://twitter.com/avraamakis) | ||
@@ -128,1 +132,5 @@ | ||
MIT | ||
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/AvraamMavridis/dugong/trend.png)](https://bitdeli.com/free "Bitdeli Badge") | ||
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
134
12921
25
9
105