-
Notifications
You must be signed in to change notification settings - Fork 13
/
index.js
49 lines (39 loc) · 1.48 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
'use strict';
/** @lends Fluxex */
var Fluxex = require('./lib/fluxex');
// jscs:disable checkRedundantParams
/**
* Create an fluxex application by provided defintion.
* @param {Object} stores - Store defination as {storeName: implement} pairs
* @param {React} HtmlJsx - The Html element defined as a React component
* @param {Object=} mixins - Extra methods/properties want to be merged into application prototype
* @returns {Object} The created fluxex application instance
* @example
var myApp = require('fluxex').createApp({
product: require('./stores/product') // Define a 'product' store
}, process.cwd() + '/components/Html.jsx'); // Your Html.jsx
*/
// jscs:enable
Fluxex.createApp = function (stores, HtmlJsx) {
var App = function FluxexApp() {
this.stores = stores;
this.HtmlJsx = HtmlJsx;
Fluxex.apply(this, arguments);
};
if (!stores) {
throw new Error('You should create app with information of stores as first parameter');
}
if (!HtmlJsx) {
throw new Error('You should create app with HtmlJsx as second parameter');
}
App.prototype = new Fluxex();
if (arguments.length > 2) {
Object.assign.apply(null, [App.prototype].concat(Array.prototype.slice.call(arguments, 2)));
}
App.prototype.constructor = App;
return App;
};
Fluxex.mixin = require('./lib/fluxmixin');
Fluxex.InitScript = require('./lib/fluxscript');
Fluxex.Title = require('./lib/fluxtitle');
module.exports = Fluxex;