@urso/core 0.7.22 → 0.7.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/build/js/index.js +1 -1
- package/package.json +1 -1
- package/src/js/lib/helper.js +3 -0
- package/src/js/lib/localData.js +17 -4
- package/src/js/modules/logic/controller.js +16 -12
package/package.json
CHANGED
package/src/js/lib/helper.js
CHANGED
|
@@ -168,6 +168,7 @@ class LibHelper {
|
|
|
168
168
|
|
|
169
169
|
/**
|
|
170
170
|
* recursive set value to object by key
|
|
171
|
+
* (*) you can use '.' as objects keys splitter
|
|
171
172
|
* @param {String} key
|
|
172
173
|
* @param {Mixed} value
|
|
173
174
|
* @param {Object} object
|
|
@@ -200,6 +201,7 @@ class LibHelper {
|
|
|
200
201
|
|
|
201
202
|
/**
|
|
202
203
|
* recursive get value from object by key
|
|
204
|
+
* (*) you can use '.' as objects keys splitter
|
|
203
205
|
* @param {String} key
|
|
204
206
|
* @param {Object} object
|
|
205
207
|
* @returns {Mixed}
|
|
@@ -222,6 +224,7 @@ class LibHelper {
|
|
|
222
224
|
|
|
223
225
|
/**
|
|
224
226
|
* recursive delete value from object by key
|
|
227
|
+
* (*) you can use '.' as objects keys splitter
|
|
225
228
|
* @param {String} key
|
|
226
229
|
* @param {Object} object
|
|
227
230
|
* @returns {Boolean}
|
package/src/js/lib/localData.js
CHANGED
|
@@ -1,13 +1,26 @@
|
|
|
1
1
|
class LibLocalData {
|
|
2
|
-
constructor(){
|
|
2
|
+
constructor() {
|
|
3
3
|
this._data = {};
|
|
4
4
|
}
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* recursive get value from local data
|
|
8
|
+
* (*) you can use '.' as objects keys splitter
|
|
9
|
+
* @param {String} key
|
|
10
|
+
* @returns {Mixed}
|
|
11
|
+
*/
|
|
12
|
+
get(name) {
|
|
7
13
|
return Urso.helper.recursiveGet(name, this._data);
|
|
8
14
|
};
|
|
9
15
|
|
|
10
|
-
|
|
16
|
+
/**
|
|
17
|
+
* recursive set value to local data
|
|
18
|
+
* (*) you can use '.' as objects keys splitter
|
|
19
|
+
* @param {String} key
|
|
20
|
+
* @param {Mixed} value
|
|
21
|
+
* @returns {Boolean}
|
|
22
|
+
*/
|
|
23
|
+
set(key, value) {
|
|
11
24
|
Urso.helper.recursiveSet(key, value, this._data);
|
|
12
25
|
return true;
|
|
13
26
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
class ModulesLogicController {
|
|
2
|
-
constructor() {
|
|
2
|
+
constructor() {
|
|
3
3
|
this._baseLogicBlocks = ['main', 'sounds'];
|
|
4
4
|
const additionalLogicBlocks = this.getAdditionalLogicBlocks();
|
|
5
5
|
this.logicBlocks = [...this._baseLogicBlocks, ...additionalLogicBlocks];
|
|
@@ -7,16 +7,16 @@ class ModulesLogicController {
|
|
|
7
7
|
this._instances = {};
|
|
8
8
|
this._init();
|
|
9
9
|
};
|
|
10
|
-
|
|
11
|
-
_init(){
|
|
10
|
+
|
|
11
|
+
_init() {
|
|
12
12
|
this._createLogicInstances();
|
|
13
13
|
};
|
|
14
14
|
|
|
15
|
-
getAdditionalLogicBlocks(){
|
|
15
|
+
getAdditionalLogicBlocks() {
|
|
16
16
|
return [];
|
|
17
17
|
};
|
|
18
18
|
|
|
19
|
-
_createLogicInstances(){
|
|
19
|
+
_createLogicInstances() {
|
|
20
20
|
//console.log('[Modules.Brain.Controller]', ' Creating logic blocks:', JSON.stringify(this.logicBlocks));
|
|
21
21
|
|
|
22
22
|
for (let i = 0; i < this.logicBlocks.length; i++) {
|
|
@@ -26,23 +26,27 @@ class ModulesLogicController {
|
|
|
26
26
|
}
|
|
27
27
|
};
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
/**
|
|
30
|
+
* launch function with current name (first agrument) per each logic block (if exists)
|
|
31
|
+
* @returns {Mixed}
|
|
32
|
+
*/
|
|
33
|
+
do() {
|
|
30
34
|
const results = [];
|
|
31
|
-
const params =
|
|
32
|
-
const
|
|
35
|
+
const params = [...arguments];
|
|
36
|
+
const functionName = params.shift();
|
|
33
37
|
|
|
34
38
|
for (let blockName in this._instances) {
|
|
35
39
|
const instance = this._instances[blockName];
|
|
36
40
|
|
|
37
|
-
if(instance && instance[
|
|
38
|
-
results[blockName] = instance[
|
|
41
|
+
if (instance && instance[functionName]) {
|
|
42
|
+
results[blockName] = instance[functionName].apply(this, params);
|
|
39
43
|
}
|
|
40
44
|
}
|
|
41
45
|
|
|
42
|
-
|
|
46
|
+
return results;
|
|
43
47
|
};
|
|
44
48
|
|
|
45
|
-
_subscribe(){};
|
|
49
|
+
_subscribe() { };
|
|
46
50
|
}
|
|
47
51
|
|
|
48
52
|
module.exports = ModulesLogicController;
|