1 | import isFunction from "lodash-es/isFunction"
|
2 | import MeasurementFramework from "./MeasurementFramework"
|
3 | import forEach from "lodash-es/forEach"
|
4 |
|
5 | let customTaskFunctions = []
|
6 |
|
7 | export default function customTask(func) {
|
8 | if (isFunction(func)) {
|
9 | customTaskFunctions.push(func)
|
10 | MeasurementFramework.register(function () {
|
11 | return {
|
12 | 'customTaskRunner': function () {
|
13 | return function (customTaskModel) {
|
14 | forEach(customTaskFunctions, function (taskFunction) {
|
15 | try {
|
16 | |
17 |
|
18 |
|
19 | taskFunction(customTaskModel)
|
20 | } catch (e) {
|
21 | console.error("customTaskRunner error: ", e.message)
|
22 | }
|
23 | })
|
24 | |
25 |
|
26 |
|
27 | }
|
28 | },
|
29 | 'customTasksRegistered': customTaskFunctions.length
|
30 | }
|
31 | })
|
32 | } else {
|
33 | console.warn("Measurement Framework received a non-function.", func)
|
34 | }
|
35 |
|
36 | } |
\ | No newline at end of file |