This repository has been archived by the owner on Nov 18, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex.js
85 lines (73 loc) · 1.87 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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
var Flux = require('./lib/flux'),
CommandHub = require('./lib/command_hub'),
EventHub = require('./lib/event_hub'),
StoreHub = require('./lib/store_hub'),
Mixin = require('./lib/mixin');
var Fluxxy = function () {
/**
* Here all Fluxxy logic happens, to couple Stores with React
* @type Flux
*/
this.Flux = new Flux(this);
/**
* Place for events
* @type EventHub
*/
this.EventHub = new EventHub();
/**
* Place for command collections
* @type CommandHub
*/
this.CommandHub = new CommandHub(this.EventHub);
/**
* Place for stores
* @type {StoreHub}
*/
this.StoreHub = new StoreHub(this.Flux, this.EventHub);
/**
* Set/get a commmand collection
* @param namespace
* @returns CommandCollection
*/
this.command = function (namespace) {
if (typeof arguments[1] != 'undefined') {
this.CommandHub.register(namespace, arguments[1]);
}
return this.CommandHub.find(namespace);
};
/**
* Set/get a store
* @param namespace
* @returns Store
*/
this.store = function (namespace) {
if (typeof arguments[1] != 'undefined') {
this.StoreHub.register(namespace, arguments[1]);
}
return this.StoreHub.find(namespace);
};
/**
* Get Fluxxy mixin
* @return FluxxyMixin
*/
this.flux = function () {
return this.Flux;
};
};
/**
* Get mixin for watching a store
* @param stores
* @returns Mixin
*/
Fluxxy.watch = function (stores) {
var component = typeof arguments[1] != 'undefined' ? arguments[1] : null;
var mixin = new Mixin(stores, component);
mixin.construct();
return mixin;
};
/**
* When implementing loading logic this is a helper string
* @type string
*/
Fluxxy.LOADING = '*fluxxy-loading-tag*';
module.exports = Fluxxy;