Comparing version 0.2.5 to 0.2.6
@@ -5,2 +5,11 @@ # Changelog | ||
## v0.2.6 | ||
* Fixed catch call in Promises [#267](https://github.com/spoike/refluxjs/pull/267) | ||
* Promise and EventEmitter is now properly exported [#258](https://github.com/spoike/refluxjs/pull/258), [#253](https://github.com/spoike/refluxjs/pull/253) | ||
* Getters in stores were accidentally invoked [#231](https://github.com/spoike/refluxjs/pull/231), [#230](https://github.com/spoike/refluxjs/pull/230) | ||
* Asynchronous actions will now return promises [#223](https://github.com/spoike/refluxjs/pull/223), [#216](https://github.com/spoike/refluxjs/issues/216), [#259](https://github.com/spoike/refluxjs/issues/259) | ||
* `dist` folder is now available again in npm package [#266](https://github.com/spoike/refluxjs/pull/266) | ||
* Fixes to README file [#260](https://github.com/spoike/refluxjs/pull/260), [#247](https://github.com/spoike/refluxjs/pull/247), [#244](https://github.com/spoike/refluxjs/pull/244), [#240](https://github.com/spoike/refluxjs/pull/240), [#236](https://github.com/spoike/refluxjs/pull/236), [#235](https://github.com/spoike/refluxjs/pull/235), [#234](https://github.com/spoike/refluxjs/pull/234) | ||
## v0.2.5 | ||
@@ -7,0 +16,0 @@ |
{ | ||
"name": "reflux", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"description": "A simple library for uni-directional dataflow application architecture inspired by ReactJS Flux", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -25,2 +25,14 @@ # RefluxJS | ||
## Content | ||
- [Comparing RefluxJS with Facebook Flux](#comparing-refluxjs-with-facebook-flux) | ||
- [Examples](#examples) | ||
- [Installation](#installation) | ||
- [Usage](#usage) | ||
- [Actions](#creating-actions) | ||
- [Stores](#creating-data-stores) | ||
- [Component](#react-component-example) | ||
- [Advanced Usage](#advanced-usage) | ||
- [Colophon](#colophon) | ||
## Comparing RefluxJS with Facebook Flux | ||
@@ -52,2 +64,4 @@ | ||
[Back to top](#content) | ||
## Examples | ||
@@ -61,2 +75,4 @@ | ||
[Back to top](#content) | ||
## Installation | ||
@@ -82,2 +98,4 @@ | ||
[Back to top](#content) | ||
## Usage | ||
@@ -87,2 +105,4 @@ | ||
[Back to top](#content) | ||
### Creating actions | ||
@@ -96,3 +116,3 @@ | ||
An action is a functor that can be invoked like any function. | ||
An action is a [function object](http://en.wikipedia.org/wiki/Function_object) that can be invoked like any function. | ||
@@ -179,3 +199,3 @@ ```javascript | ||
Asynchronous actions can used as promises, which is particularly useful for server-side rendering when you must await the successful (or failed) completion of an action before rendering. | ||
Asynchronous actions can be used as promises, which is particularly useful for server-side rendering when you must await the successful (or failed) completion of an action before rendering. | ||
@@ -209,3 +229,3 @@ Suppose you had an action + store to make an API request: | ||
```javascript | ||
makeRequest('/api/something').then(function(body) { | ||
makeRequest.triggerPromise('/api/something').then(function(body) { | ||
// Render the response body | ||
@@ -260,2 +280,4 @@ }).catch(function(err) { | ||
[Back to top](#content) | ||
### Creating data stores | ||
@@ -429,2 +451,5 @@ | ||
``` | ||
[Back to top](#content) | ||
### React component example | ||
@@ -524,7 +549,7 @@ | ||
var PostView = React.createClass({ | ||
mixins: [Reflux.connectFilter(postStore,"post", function(posts) { | ||
posts.filter(function(post) { | ||
post.id === this.props.id; | ||
}); | ||
}], | ||
mixins: [Reflux.connectFilter(postStore, "post", function(posts) { | ||
return posts.filter(function(post) { | ||
return post.id === this.props.id; | ||
}.bind(this))[0]; | ||
})], | ||
render: function() { | ||
@@ -563,2 +588,5 @@ // render using `this.state.post` | ||
``` | ||
[Back to top](#content) | ||
## Advanced usage | ||
@@ -684,2 +712,4 @@ | ||
[Back to top](#content) | ||
## Colophon | ||
@@ -686,0 +716,0 @@ |
module.exports = function(store, definition) { | ||
for (var name in definition) { | ||
var property = definition[name]; | ||
if (Object.getOwnPropertyDescriptor && Object.defineProperty) { | ||
var propertyDescriptor = Object.getOwnPropertyDescriptor(definition, name); | ||
if (typeof property !== 'function' || !definition.hasOwnProperty(name)) { | ||
continue; | ||
if (!propertyDescriptor.value || typeof propertyDescriptor.value !== 'function' || !definition.hasOwnProperty(name)) { | ||
continue; | ||
} | ||
store[name] = definition[name].bind(store); | ||
} else { | ||
var property = definition[name]; | ||
if (typeof property !== 'function' || !definition.hasOwnProperty(name)) { | ||
continue; | ||
} | ||
store[name] = property.bind(store); | ||
} | ||
store[name] = property.bind(store); | ||
} | ||
@@ -11,0 +21,0 @@ |
@@ -54,3 +54,3 @@ var _ = require('./utils'), | ||
var functor = function() { | ||
functor[functor.sync?"trigger":"triggerAsync"].apply(functor, arguments); | ||
return functor[functor.sync?"trigger":"triggerPromise"].apply(functor, arguments); | ||
}; | ||
@@ -57,0 +57,0 @@ |
@@ -36,2 +36,6 @@ exports.ActionMethods = require('./ActionMethods'); | ||
exports.EventEmitter = _.EventEmitter; | ||
exports.Promise = _.Promise; | ||
/** | ||
@@ -59,3 +63,3 @@ * Convenience function for creating a set of actions | ||
var _ = require('./utils'); | ||
_.EventEmitter = ctx; | ||
exports.EventEmitter = _.EventEmitter = ctx; | ||
}; | ||
@@ -69,5 +73,6 @@ | ||
var _ = require('./utils'); | ||
_.Promise = ctx; | ||
exports.Promise = _.Promise = ctx; | ||
}; | ||
/** | ||
@@ -74,0 +79,0 @@ * Sets the Promise factory that creates new promises |
@@ -64,5 +64,3 @@ var _ = require('./utils'); | ||
return me.completed(response); | ||
}); | ||
// IE compatibility - catch is a reserved word - without bracket notation source compilation will fail under IE | ||
promise["catch"](function(error) { | ||
}, function(error) { | ||
return me.failed(error); | ||
@@ -127,20 +125,22 @@ }); | ||
if (!canHandlePromise){ | ||
throw new Error('Publisher must have "completed" and "failed" child publishers'); | ||
} | ||
var promise = _.createPromise(function(resolve, reject) { | ||
var removeSuccess = me.completed.listen(function(args) { | ||
removeSuccess(); | ||
removeFailed(); | ||
resolve(args); | ||
}); | ||
if (canHandlePromise) { | ||
var removeSuccess = me.completed.listen(function(args) { | ||
removeSuccess(); | ||
removeFailed(); | ||
resolve(args); | ||
}); | ||
var removeFailed = me.failed.listen(function(args) { | ||
removeSuccess(); | ||
removeFailed(); | ||
reject(args); | ||
}); | ||
var removeFailed = me.failed.listen(function(args) { | ||
removeSuccess(); | ||
removeFailed(); | ||
reject(args); | ||
}); | ||
} | ||
me.triggerAsync.apply(me, args); | ||
if (!canHandlePromise) { | ||
resolve(); | ||
} | ||
}); | ||
@@ -147,0 +147,0 @@ |
@@ -18,3 +18,8 @@ /* | ||
for (prop in source) { | ||
obj[prop] = source[prop]; | ||
if (Object.getOwnPropertyDescriptor && Object.defineProperty) { | ||
var propertyDescriptor = Object.getOwnPropertyDescriptor(source, prop); | ||
Object.defineProperty(obj, prop, propertyDescriptor); | ||
} else { | ||
obj[prop] = source[prop]; | ||
} | ||
} | ||
@@ -21,0 +26,0 @@ } |
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
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
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
137498
31
2113
722
3
4