Comparing version 0.0.2 to 0.0.3
@@ -8,5 +8,27 @@ module.exports = function(grunt) { | ||
}, | ||
mochaTest: { | ||
test: { | ||
src: ['test/**/*.spec.js'] | ||
} | ||
}, | ||
browserify: { | ||
dist: { | ||
src: ['src/index.js'], | ||
dest: 'dist/<%= pkg.name %>.js', | ||
options: { | ||
bundleOptions: { | ||
standalone: 'Reflux' | ||
} | ||
}, | ||
} | ||
}, | ||
uglify: { | ||
dist: { | ||
src: 'dist/reflux.js', | ||
dest: 'dist/reflux.min.js' | ||
} | ||
}, | ||
watch: { | ||
files: ['<%= jshint.files %>'], | ||
tasks: ['jshint'] | ||
tasks: ['build'] | ||
} | ||
@@ -17,6 +39,8 @@ }); | ||
grunt.registerTask('test', ['jshint']); | ||
grunt.registerTask('test', ['jshint', 'mochaTest']); | ||
grunt.registerTask('default', ['jshint']); | ||
grunt.registerTask('build', ['test', 'browserify', 'uglify']); | ||
grunt.registerTask('default', ['watch']); | ||
}; |
{ | ||
"name": "reflux", | ||
"version": "0.0.2", | ||
"version": "0.0.3", | ||
"description": "A simple library for uni-directional dataflow application architecture inspired by ReactJS Flux", | ||
@@ -15,2 +15,10 @@ "main": "src/index.js", | ||
}, | ||
"browserify": { | ||
"transform": [ | ||
"browserify-shim" | ||
] | ||
}, | ||
"browserify-shim": { | ||
"lodash": "global:_" | ||
}, | ||
"dependencies": { | ||
@@ -20,7 +28,14 @@ "lodash": "~2.4.1" | ||
"devDependencies": { | ||
"browserify": "^4.2.0", | ||
"browserify-shim": "^3.6.0", | ||
"chai": "^1.9.1", | ||
"grunt": "^0.4.5", | ||
"grunt-browserify": "^2.1.2", | ||
"grunt-contrib-jshint": "^0.10.0", | ||
"grunt-contrib-uglify": "^0.5.0", | ||
"grunt-contrib-watch": "^0.6.1", | ||
"matchdep": "^0.3.0" | ||
"grunt-mocha-test": "^0.11.0", | ||
"matchdep": "^0.3.0", | ||
"q": "^1.0.1" | ||
} | ||
} |
@@ -5,3 +5,3 @@ # Reflux | ||
# Installation | ||
## Installation | ||
@@ -12,61 +12,67 @@ You can currently install the package as a npm package: | ||
# Usage | ||
## Usage | ||
Create an action by calling `createAction`. | ||
var Reflux = require('reflux'); | ||
```javascript | ||
var Reflux = require('reflux'); | ||
var statusUpdate = Reflux.createAction(); | ||
var statusUpdate = Reflux.createAction(); | ||
``` | ||
Create a data store by passing a definition object to `createStore`. | ||
// Creates a DataStore | ||
var statusStore = Reflux.createStore({ | ||
```javascript | ||
// Creates a DataStore | ||
var statusStore = Reflux.createStore({ | ||
// Initial setup | ||
init: function() { | ||
// Initial setup | ||
init: function() { | ||
// Register statusUpdate action | ||
this.listenTo(statusUpdate, this.output); | ||
}, | ||
// Register statusUpdate action | ||
this.listenTo(statusUpdate, this.output); | ||
}, | ||
// Callback | ||
output: function(flag) { | ||
var status = flag ? 'ONLINE' : 'OFFLINE'; | ||
this.trigger(status); | ||
} | ||
// Callback | ||
output: function(flag) { | ||
var status = flag ? 'ONLINE' : 'OFFLINE'; | ||
this.trigger(status); | ||
} | ||
}); | ||
}); | ||
``` | ||
In your component, register to listen to your data store like this: | ||
// Fairly simple view component that outputs to console | ||
function ConsoleComponent() { | ||
```javascript | ||
// Fairly simple view component that outputs to console | ||
function ConsoleComponent() { | ||
// Registers a console logging callback to the statusStore updates | ||
statusStore.listen(function(status) { | ||
console.log('status: ', status); | ||
}); | ||
}; | ||
// Registers a console logging callback to the statusStore updates | ||
statusStore.listen(function(status) { | ||
console.log('status: ', status); | ||
}); | ||
}; | ||
var consoleComponent = new ConsoleComponent(); | ||
var consoleComponent = new ConsoleComponent(); | ||
``` | ||
Invoke actions as if they were functions: | ||
statusUpdate(true); | ||
statusUpdate(false); | ||
```javascript | ||
statusUpdate(true); | ||
statusUpdate(false); | ||
/** | ||
* Will output: | ||
* status: ONLINE | ||
* status: OFFLINE | ||
* | ||
*/ | ||
/** | ||
* Will output: | ||
* status: ONLINE | ||
* status: OFFLINE | ||
*/ | ||
``` | ||
See `test/index.js` for more example on how to use the package. | ||
# License | ||
## License | ||
## [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) | ||
### [BSD 3-Clause License](http://opensource.org/licenses/BSD-3-Clause) | ||
@@ -73,0 +79,0 @@ Copyright (c) 2014, Mikael Brassman |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
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
28582
13
571
88
11
3
4
1