-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRunConfig.ts
73 lines (62 loc) · 2.52 KB
/
RunConfig.ts
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
import React from 'react';
import { makeAutoObservable } from 'mobx';
import { AbTesting } from './ABTesting';
/**
* Holds information about how to run the app. MobX automatically updates the UI
* when RunConfig properties change, but you should only do this during development.
*
* When creating components, you may define a {@link playground} for that
* component. When the app runs, it will run it instead of the regular app.
*/
class RunConfig {
/** If you define a playground, it will be shown instead of the regular app. */
playground: React.JSX.Element | null | undefined;
/** If the use can see and change the RunConfig options in the Configuration Screen. */
ifShowRunConfigInTheConfigScreen: boolean;
/** Only if true, the {@link print} function will print to the console. */
ifPrintsDebugInfoToConsole: boolean;
/** Choose between different UIs. Add more states than simple A/B, as needed. */
abTesting: AbTesting;
public constructor({
playground,
ifShowRunConfigInTheConfigScreen,
ifPrintsDebugInfoToConsole,
abTesting,
}: {
playground: React.JSX.Element | null | undefined;
ifShowRunConfigInTheConfigScreen: boolean;
ifPrintsDebugInfoToConsole: boolean;
abTesting: AbTesting;
}) {
this.playground = playground;
this.ifShowRunConfigInTheConfigScreen = ifShowRunConfigInTheConfigScreen;
this.ifPrintsDebugInfoToConsole = ifPrintsDebugInfoToConsole;
this.abTesting = abTesting;
makeAutoObservable(this);
}
set({
playground,
ifShowRunConfigInTheConfigScreen,
ifPrintsDebugInfoToConsole,
abTesting,
}: {
playground?: React.JSX.Element | null,
ifShowRunConfigInTheConfigScreen?: boolean,
ifPrintsDebugInfoToConsole?: boolean,
abTesting?: AbTesting,
}) {
if (playground !== undefined) this.playground = playground;
if (ifShowRunConfigInTheConfigScreen !== undefined) this.ifShowRunConfigInTheConfigScreen = ifShowRunConfigInTheConfigScreen;
if (ifPrintsDebugInfoToConsole !== undefined) this.ifPrintsDebugInfoToConsole = ifPrintsDebugInfoToConsole;
if (abTesting !== undefined) this.abTesting = abTesting;
}
toString(): string {
return `
playground: ${this.playground?.constructor.name}
ifShowRunConfigInTheConfigScreen: ${this.ifShowRunConfigInTheConfigScreen}
ifPrintsDebugInfoToConsole: ${this.ifPrintsDebugInfoToConsole}
abTesting: ${this.abTesting}
`;
}
}
export default RunConfig;