neo.mjs 6.15.5 → 6.15.6

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.
Files changed (60) hide show
  1. package/apps/ServiceWorker.mjs +2 -2
  2. package/apps/form/view/FormContainerController.mjs +1 -1
  3. package/apps/form/view/ViewportController.mjs +2 -2
  4. package/apps/portal/view/home/MainContainer.mjs +2 -2
  5. package/apps/portal/view/learn/ContentView.mjs +1 -1
  6. package/apps/portal/view/learn/LivePreview.mjs +0 -27
  7. package/apps/realworld2/view/user/LoginFormContainer.mjs +1 -1
  8. package/docs/app/view/MainContainer.mjs +1 -11
  9. package/examples/ServiceWorker.mjs +2 -2
  10. package/examples/component/timer/MainContainerController.mjs +2 -2
  11. package/examples/component/toast/MainContainerController.mjs +2 -2
  12. package/examples/date/selectorContainer/MainContainer.mjs +215 -0
  13. package/examples/date/selectorContainer/app.mjs +6 -0
  14. package/examples/date/selectorContainer/index.html +11 -0
  15. package/examples/date/selectorContainer/neo-config.json +6 -0
  16. package/package.json +3 -3
  17. package/resources/data/deck/learnneo/pages/Welcome.md +8 -0
  18. package/resources/data/deck/learnneo/pages/WhyNeo-Speed.md +5 -3
  19. package/resources/data/deck/learnneo/tree.json +4 -4
  20. package/resources/scss/src/date/SelectorContainer.scss +120 -0
  21. package/resources/scss/theme-dark/date/SelectorContainer.scss +24 -0
  22. package/resources/scss/theme-light/date/SelectorContainer.scss +24 -0
  23. package/resources/scss/theme-neo-light/date/SelectorContainer.scss +24 -0
  24. package/src/DefaultConfig.mjs +2 -2
  25. package/src/Neo.mjs +5 -5
  26. package/src/component/Base.mjs +1 -1
  27. package/src/container/Base.mjs +42 -17
  28. package/src/controller/Component.mjs +5 -4
  29. package/src/core/Observable.mjs +30 -5
  30. package/src/core/Util.mjs +1 -1
  31. package/src/date/DayViewComponent.mjs +251 -0
  32. package/src/date/SelectorContainer.mjs +352 -0
  33. package/src/date/SelectorContainerModel.mjs +33 -0
  34. package/src/form/Container.mjs +10 -2
  35. package/src/form/field/Base.mjs +10 -2
  36. package/src/form/field/CheckBox.mjs +13 -5
  37. package/src/form/field/ComboBox.mjs +20 -15
  38. package/src/form/field/Date.mjs +2 -2
  39. package/src/form/field/Text.mjs +18 -17
  40. package/src/main/addon/IntersectionObserver.mjs +27 -20
  41. package/src/tab/Container.mjs +56 -55
  42. package/docs/app/model/Tutorial.mjs +0 -41
  43. package/docs/app/store/Tutorials.mjs +0 -28
  44. package/docs/app/view/TutorialsTreeList.mjs +0 -51
  45. package/docs/tutorials/01_Concept.html +0 -45
  46. package/docs/tutorials/01_Concept.json +0 -123
  47. package/docs/tutorials/01_Concept.md +0 -55
  48. package/docs/tutorials/02_ClassSystem.html +0 -171
  49. package/docs/tutorials/02_ClassSystem.md +0 -187
  50. package/docs/tutorials/03_ComponentLifecycle.html +0 -28
  51. package/docs/tutorials/03_ComponentLifecycle.md +0 -23
  52. package/docs/tutorials/04_VdomVnode.html +0 -161
  53. package/docs/tutorials/05_RemoteMethodAccess.html +0 -82
  54. package/docs/tutorials/06_EcmaScript6Plus.html +0 -10
  55. package/docs/tutorials/07_WebWorkers.html +0 -9
  56. package/docs/tutorials/08_DomEvents.html +0 -7
  57. package/docs/tutorials/09_TodoList_version1.html +0 -503
  58. package/docs/tutorials/11_CreateApp.html +0 -94
  59. package/docs/tutorials/tutorials.json +0 -100
  60. package/resources/scss/src/apps/docs/TutorialsTreeList.scss +0 -7
@@ -1,123 +0,0 @@
1
- [
2
- {
3
- "tag": "div",
4
- "cls": ["neo-header-text-container"],
5
- "cn" : [
6
- {
7
- "tag" : "span",
8
- "cls" : ["neo-header-text"],
9
- "innerHTML": "Tutorial: Concept"
10
- }
11
- ]
12
- },
13
- {
14
- "tag": "article",
15
- "cn" : [
16
- {
17
- "tag" : "h4",
18
- "innerHTML": "Why yet another Javascript framework?"
19
- },
20
- {
21
- "tag": "ol",
22
- "cn" : [
23
- {
24
- "tag" : "li",
25
- "innerHTML": "neo.mjs is web workers driven"
26
- },
27
- {
28
- "tag" : "li",
29
- "innerHTML": "neo.mjs does not need any cryptic XML markups"
30
- },
31
- {
32
- "tag" : "li",
33
- "innerHTML": "neo.mjs uses a custom blazing fast virtual dom engine"
34
- },
35
- {
36
- "tag" : "li",
37
- "innerHTML": "neo.mjs is based on EcmaScript 8 (ES8)"
38
- },
39
- {
40
- "tag" : "li",
41
- "innerHTML": "neo.mjs uses HTML5 and CSS3 to the fullest"
42
- },
43
- {
44
- "tag" : "li",
45
- "innerHTML": "Simplicity"
46
- },
47
- {
48
- "tag" : "li",
49
- "innerHTML": "No transpiled code"
50
- }
51
- ]
52
- },
53
- {
54
- "tag": "hr"
55
- },
56
- {
57
- "tag" : "p",
58
- "innerHTML": "(1) neo.mjs uses 3 web workers:"
59
- },
60
- {
61
- "tag": "ul",
62
- "cn": [
63
- {
64
- "tag" : "li",
65
- "innerHTML": "App"
66
- },
67
- {
68
- "tag" : "li",
69
- "innerHTML": "Data"
70
- },
71
- {
72
- "tag" : "li",
73
- "innerHTML": "Vdom"
74
- }
75
- ]
76
- },
77
- {
78
- "tag" : "p",
79
- "innerHTML": "The main reason is that browsers by default only use 1 CPU core, while most computers and mobile devices have more. Multi-Threading solves this performance bottleneck and it will ensure that there are no hidden background-tasks in the main thread, which mess with your beautiful animations."
80
- },
81
- {
82
- "tag" : "p",
83
- "innerHTML": "In short: Most parts of neo.mjs as well as all apps you will create are inside the App worker."
84
- },
85
- {
86
- "tag" : "p",
87
- "innerHTML": "The main thread is only responsible to manipulate the DOM and delegate DOM events to the App worker."
88
- },
89
- {
90
- "tag" : "p",
91
- "innerHTML": "The Data worker will perform all Ajax requests to your backend and host the Store instances."
92
- },
93
- {
94
- "tag" : "p",
95
- "innerHTML": "The Vdom worker parses your JSON based markup (Vdom) into a virtual node (Vnode) and creates deltas when you dynamically change your Vdom."
96
- },
97
- {
98
- "tag" : "p",
99
- "innerHTML": "(2) Did you ever enjoy writing pseudo-html including curly braces like {tpl if}, {tpl for} or even better {[this.doSomething()]}? Those XML templates evolved to a point, where they try to do everything what Javascript itself is capable of and you will most likely have encountered scoping issues (where does "this" point to now?). The solution is as simple as it should have been obvious for quite a while: JSON. You can easily manipulate Javascript objects with Javascript."
100
- },
101
- {
102
- "tag" : "p",
103
- "innerHTML": "(3) Since neo.mjs does not need to parse XML templates back into JSON and then create virtual DOM nodes, the custom Vdom engine is blazing fast. The algorithms to create deltas are highly efficient and recognise moved DOM subtrees immediately."
104
- },
105
- {
106
- "tag" : "p",
107
- "innerHTML": "(4) neo.mjs is most likely the first UI framework out there which does not only allow devs to create ES8 classes on top of ES5 prototypes, but is itself fully written in ES8."
108
- },
109
- {
110
- "tag" : "p",
111
- "innerHTML": "(5) neo.mjs uses the latest web APIs and CSS features to the fullest and give you an easy and intuitive access to them."
112
- },
113
- {
114
- "tag" : "p",
115
- "innerHTML": "(6) The first and most important design goal of neo.mjs is simplicity. This does not only mean to keep the code base as clean and simple as possible, but also to keep the created DOM as lightweight and minimal as possible."
116
- },
117
- {
118
- "tag" : "p",
119
- "innerHTML": "(7) neo.mjs does not use Babel or any other tool to transpile code (which does not mean you can't use it for your own apps)."
120
- }
121
- ]
122
- }
123
- ]
@@ -1,55 +0,0 @@
1
- #### Why yet another Javascript framework?
2
-
3
- 1. neo.mjs is web workers driven
4
- 2. neo.mjs does not need any cryptic XML markups
5
- 3. neo.mjs uses a custom blazing fast virtual dom engine
6
- 4. neo.mjs is based on EcmaScript 8 (ES8)
7
- 5. neo.mjs uses HTML5 and CSS3 to the fullest
8
- 6. Simplicity
9
- 7. No transpiled code
10
-
11
- ____
12
-
13
- (1) neo.mjs uses 3 web workers:
14
- * App
15
- * Data
16
- * Vdom
17
-
18
- The main reason is that browsers by default only use 1 CPU core, while most computers and mobile devices have
19
- more. Multi-Threading solves this performance bottleneck and it will ensure that there are no hidden
20
- background-tasks in the main thread, which mess with your beautiful animations.
21
-
22
- In short: Most parts of neo.mjs as well as all apps you will create are inside the App worker.
23
-
24
- The main thread is only responsible to manipulate the DOM and delegate DOM events to the App worker.
25
-
26
- The Data worker will perform all Ajax requests to your backend and host the Store instances.
27
-
28
- The Vdom worker parses your JSON based markup (Vdom) into a virtual node (Vnode) and creates deltas
29
- when you dynamically change your Vdom.
30
-
31
-
32
- (2) Did you ever enjoy writing pseudo-html including curly braces like {tpl if}, {tpl for} or even better
33
- {[this.doSomething()]}? Those XML templates evolved to a point, where they try to do everything what
34
- Javascript itself is capable of and you will most likely have encountered scoping issues (where does "this"
35
- point to now?). The solution is as simple as it should have been obvious for quite a while: JSON. You can easily manipulate Javascript objects with Javascript.
36
-
37
-
38
- (3) Since neo.mjs does not need to parse XML templates back into JSON and then create virtual DOM nodes,
39
- the custom Vdom engine is blazing fast. The algorithms to create deltas are highly efficient and
40
- recognise moved DOM subtrees immediately.
41
-
42
-
43
- (4) neo.mjs is most likely the first UI framework out there which does not only allow devs to create
44
- ES6 classes on top of ES5 prototypes, but is itself fully written in ES6.
45
-
46
-
47
- (5) neo.mjs uses the latest web APIs and CSS features to the fullest and give you an easy and intuitive
48
- access to them.
49
-
50
-
51
- (6) The first and most important design goal of neo.mjs is simplicity. This does not only mean to keep the
52
- code base as clean and simple as possible, but also to keep the created DOM as lightweight and minimal as
53
- possible.
54
-
55
- (7) neo.mjs does not use Babel or any other tool to transpile code (which does not mean you can't use it for your own apps).
@@ -1,171 +0,0 @@
1
- <div class="neo-header-text-container">
2
- <span class="neo-header-text">Tutorial: Class System</span>
3
- </div>
4
- <article>
5
- <ol>
6
- <li>Flaws of the ES6+ class system
7
- <ol>
8
- <li>No &quot;this&quot; inside constructors before the parent call</li>
9
- <li>It is not possible to define properties inside the class body without using get &amp; set</li>
10
- <li>No private methods or properties</li>
11
- <li>No support for mixins</li>
12
- </ol>
13
- </li>
14
- <li>Neo Modules &amp; Classes
15
- <ol>
16
- <li>One Class per File</li>
17
- <li>Each Class is &quot;wrapped&quot; inside a JS Module</li>
18
- <li>Private Class methods</li>
19
- <li>*.mjs</li>
20
- </ol>
21
- </li>
22
- <li>Neo ES6+ Class Enhancements
23
- <ol>
24
- <li>Neo.applyClassConfig</li>
25
- <li>Reducing boiler plate code</li>
26
- </ol>
27
- </li>
28
- </ol>
29
- <h4>(1) Flaws of the ES6+ class system</h4>
30
- <p>(1.1.) This might not sound like a big deal at first, but it does prevent any pre-processing inside the
31
- constructor chain.</p>
32
- <pre><code>class TabContainer extends Container {
33
- construct(config) {
34
- //let me = this; // breaks!
35
- super.construct(config);
36
- let me = this; //ok
37
- }
38
- }</code></pre>
39
- <p>(1.2.) The most likely biggest flaw is that you can not define any properties directly inside the class body,
40
- as well as a missing config system.</p>
41
- <pre><code>class TabContainer extends Container {
42
- activeIndex: 1 // nope
43
- static foo: 'bar' // impossible as well
44
- }</code></pre>
45
- <p>There is hope: <a target="_blank" href="https://tc39.github.io/proposal-class-fields/#sec-private-bound-names">https://tc39.github.io/proposal-class-fields/#sec-private-bound-names</a>
46
- </p>
47
- <p>(1.3.) Although there are some proposals out there for many years, still not implemented.</p>
48
- <p>(1.4.) Independant whether you like the mixin pattern or not, it is just not possible.</p>
49
- <hr>
50
- <h4>(2) Neo Modules &amp; Classes</h4>
51
- <p>(2.1.) One Class per File. Might sound trivial from classic OOP concepts, but we do stick to it and recommend you
52
- to
53
- do the same for your application files.</p>
54
- <p>(2.2) As soon as you want to extend an ES6+ class, you need to ensure that the base class is available.
55
- One good way to achieve this is to use import:</p>
56
- <p><a target="_blank" href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import">https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import</a>
57
- </p>
58
- <p>This automatially makes the file a JS module and you will notice that we will at least export the Class
59
- at the end of of each module.</p>
60
- <p>(2.3) Having the JS Module around each Class definition allows us to place methods outside of the class
61
- deinition,
62
- but still between the import and export statements. A nice place for &quot;private&quot; methods or attributes
63
- which can get
64
- accessed from Class methods easily, but not as easy from the outside world.</p>
65
- <p>(2.4.) In case you missed it, *.mjs is not something we came up with, but the new standard file extension name
66
- for
67
- Javascript Modules. You can find more details e.g. in Axels Blog:</p>
68
- <p>
69
- <a target="_blank" href="http://2ality.com/2017/05/es-module-specifiers.html">http://2ality.com/2017/05/es-module-specifiers.html</a>
70
- </p>
71
- <hr>
72
- <h4>(3) Neo ES6+ Class Enhancements</h4>
73
- <p>(3.1.) To reduce the issue of 1.2. we created Neo.applyClassConfig (Neo.mjs),
74
- which does get called in every Class File at the very bottom (before the export statement).
75
- If you look at Neo Class / Module files, like component/Button.mjs, you will notice 2 methods at the top of the
76
- class body:</p>
77
- <h5>getStaticConfig</h5><h5>getConfig</h5>
78
- <p>Both methods simply return an object. Put all static keys into getStaticConfig and all other ones into getConfig.
79
- Neo.applyClassConfig <strong>(strongly recommended to look at the source code)</strong> will apply all static
80
- configs to the class
81
- constructor (as well as adding the staticConfig object itself there) and all non static configs will get added
82
- using
83
- Object.defineProperty() on the Class prototype.</p>
84
- <p>So, why is a &quot;config system&quot; useful, you might ask yourself at this point.
85
- This can easily get showcased using a simple example:</p>
86
- <pre><code>class TabContainer extends Container {
87
- get activeIndex() {
88
- return this._activeIndex || 0;
89
- }
90
- set activeIndex(value) {
91
- this._activeIndex = value;
92
- }
93
- }</code></pre>
94
- <p>So far so good, we now have an activeIndex property which will use _activeIndex to read &amp; save its value.
95
- Now you might want to extend this class:</p>
96
- <pre><code>class MyTabContainer extends TabContainer {
97
- static getConfig() {return {
98
- _activeIndex: 1
99
- }}
100
- }</code></pre>
101
- <p>Ok, this one was easy. _activeIndex will get applied as a class property.
102
- Neither the first version with 0 nor the second one using the underscore and the value of 1 will trigger the
103
- setter.
104
- When you call:</p>
105
- <pre><code>Neo.create(MyTabContainer);</code></pre>
106
- <p>the constructor of our Base Class (Neo.core.Base) will call initConfig(),
107
- which will apply _activeIndex to the instance, silently setting the value</p>
108
- <pre><code>class MyTabContainer2 extends TabContainer {
109
- static getConfig() {return {
110
- activeIndex: 1
111
- }}
112
- }</code></pre>
113
- <p>Now it does get more interesting. You want to trigger the setter when creating an instance,
114
- but you definitely do <strong>not</strong> want to override the activeIndex property defined via get &amp; set
115
- with the new one.
116
- No worries, Neo.applyClassConfig will check the base class prototype chain and in case it does find a property
117
- with the
118
- same name, it will not override the version having the setter. Instead it will only apply activeIndex inside the
119
- config
120
- object itself.
121
- Now, when you call:</p>
122
- <pre><code>Neo.create(MyTabContainer2);</code></pre>
123
- <p>the constructor of our Base Class (Neo.core.Base) will call initConfig(),
124
- which will apply activeIndex to your instance and this will call the setter.</p>
125
- <pre><code>Neo.create(MyTabContainer2, {
126
- activeIndex: 2
127
- });</code></pre>
128
- <p>This will also call the setter <strong>once</strong>, this time using the value of 2
129
- (initConfig does merge the prototype config object with the one you pass into Neo.create -&gt; the constructor)
130
- </p>
131
- <p>(3.2.) Reducing boiler plate code. When looking back at the first TabContainer example you will probably think:
132
- Damn, in case I want to define many properties via get&amp;set which all just save&amp;get their value inside an
133
- undercored
134
- version of its name key, this will create quite some overhead.</p>
135
- <p>To avoid this and make your code more beautiful, we added a trailing underscore for class configs:</p>
136
- <pre><code>class TabContainer extends Container {
137
- static getConfig() {return {
138
- activeIndex_: 0
139
- }}
140
- }</code></pre>
141
- <p>Look close: activeIndex<span style="color:red;font-size:200%;">_</span> .This gets you the exact same result as
142
- the previous example:</p>
143
- <pre><code>class TabContainer extends Container {
144
- get activeIndex() {
145
- return this._activeIndex || 0;
146
- }
147
- set activeIndex(value) {
148
- this._activeIndex = value;
149
- }
150
- }</code></pre>
151
- <p>Even better, this also <strong>optionally</strong> gives you support for 3 more methods you can use:</p>
152
- <pre><code>class TabContainer extends Container {
153
- static getConfig() {return {
154
- activeIndex_: 0
155
- }}
156
-
157
- beforeSetActiveIndex(value, oldValue) {
158
- return 42; // the answer to Life, the Universe, and Everything
159
- }
160
-
161
- beforeGetActiveIndex(value) {
162
- return 5; // but hey, why tell anyone?
163
- }
164
-
165
- // this one would only get called in case value !== oldValue
166
- afterSetActiveIndex(value, oldValue) {
167
- // update the UI
168
- }
169
- }</code></pre>
170
- <p><a href="module-Neo.html#~autoGenerateGetSet">Details here</a></p>
171
- </article>
@@ -1,187 +0,0 @@
1
- 1. Flaws of the ES6 class system
2
- 1. No "this" inside constructors before the parent call
3
- 2. It is not possible to define properties inside the class body without using get & set
4
- 3. No private methods or properties
5
- 4. No support for mixins
6
- 2. Neo Modules & Classes
7
- 1. One Class per File
8
- 2. Each Class is "wrapped" inside a JS Module
9
- 3. Private Class methods
10
- 4. *.mjs
11
- 3. Neo ES6 Class Enhancements
12
- 1. Neo.applyClassConfig
13
- 2. Reducing boiler plate code
14
-
15
- #### (1) Flaws of the ES6 class system
16
-
17
- (1.1.) This might not sound like a big deal at first, but it does prevent any pre-processing inside the constructor chain.
18
- ```
19
- class TabContainer extends Container {
20
- construct(config) {
21
- //let me = this; // breaks!
22
- super.construct(config);
23
- let me = this; //ok
24
- }
25
- }
26
- ```
27
-
28
- (1.2.) The most likely biggest flaw is that you can not define any properties directly inside the class body,
29
- as well as a missing config system.
30
- ```
31
- class TabContainer extends Container {
32
- activeIndex: 1 // nope
33
- static foo: 'bar' // impossible as well
34
- }
35
- ```
36
- There is hope: <https://tc39.github.io/proposal-class-fields/#sec-private-bound-names>
37
-
38
- (1.3.) Although there are some proposals out there for many years, still not implemented.
39
-
40
- (1.4.) Independant whether you like the mixin pattern or not, it is just not possible.
41
-
42
- - - - -
43
-
44
- #### (2) Neo Modules & Classes
45
-
46
- (2.1.) One Class per File. Might sound trivial from classic OOP concepts, but we do stick to it and recommend you to
47
- do the same for your application files.
48
-
49
- (2.2) As soon as you want to extend an ES6 class, you need to ensure that the base class is available.
50
- One good way to achieve this is to use import:
51
-
52
- <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import>
53
-
54
- This automatially makes the file a JS module and you will notice that we will at least export the Class
55
- at the end of of each module.
56
-
57
- (2.3) Having the JS Module around each Class definition allows us to place methods outside of the class deinition,
58
- but still between the import and export statements. A nice place for "private" methods or attributes which can get
59
- accessed from Class methods easily, but not as easy from the outside world.
60
-
61
- (2.4.) In case you missed it, *.mjs is not something we came up with, but the new standard file extension name for
62
- Javascript Modules. You can find more details e.g. in Axels Blog:
63
-
64
- <http://2ality.com/2017/05/es-module-specifiers.html>
65
-
66
- - - - -
67
-
68
- #### (3) Neo ES6 Class Enhancements
69
-
70
- (3.1.) To reduce the issue of 1.2. we created Neo.applyClassConfig (Neo.mjs),
71
- which does get called in every Class File at the very bottom (before the export statement).
72
- If you look at Neo Class / Module files, like component/Button.mjs, you will notice 2 methods at the top of the class body:
73
-
74
- ##### getStaticConfig
75
-
76
- ##### getConfig
77
-
78
- Both methods simply return an object. Put all static keys into getStaticConfig and all other ones into getConfig.
79
- Neo.applyClassConfig **(strongly recommended to look at the source code)** will apply all static configs to the class
80
- constructor (as well as adding the staticConfig object itself there) and all non static configs will get added using
81
- Object.defineProperty() on the Class prototype.
82
-
83
- So, why is a "config system" useful, you might ask yourself at this point.
84
- This can easily get showcased using a simple example:
85
-
86
- ```
87
- class TabContainer extends Container {
88
- get activeIndex() {
89
- return this._activeIndex || 0;
90
- }
91
- set activeIndex(value) {
92
- this._activeIndex = value;
93
- }
94
- }
95
- ```
96
- So far so good, we now have an activeIndex property which will use _activeIndex to read & save its value.
97
- Now you might want to extend this class:
98
- ```
99
- class MyTabContainer extends TabContainer {
100
- static getConfig() {return {
101
- _activeIndex: 1
102
- }}
103
- }
104
- ```
105
- Ok, this one was easy. _activeIndex will get applied as a class property.
106
- Neither the first version with 0 nor the second one using the underscore and the value of 1 will trigger the setter.
107
- When you call:
108
- ```
109
- Neo.create(MyTabContainer);
110
- ```
111
- the constructor of our Base Class (Neo.core.Base) will call initConfig(),
112
- which will apply _activeIndex to the instance, silently setting the value
113
-
114
- ```
115
- class MyTabContainer2 extends TabContainer {
116
- static getConfig() {return {
117
- activeIndex: 1
118
- }}
119
- }
120
- ```
121
- Now it does get more interesting. You want to trigger the setter when creating an instance,
122
- but you definitely do **not** want to override the activeIndex property defined via get & set with the new one.
123
- No worries, Neo.applyClassConfig will check the base class prototype chain and in case it does find a property with the
124
- same name, it will not override the version having the setter. Instead it will only apply activeIndex inside the config
125
- object itself.
126
- Now, when you call:
127
- ```
128
- Neo.create(MyTabContainer2);
129
- ```
130
- the constructor of our Base Class (Neo.core.Base) will call initConfig(),
131
- which will apply activeIndex to your instance and this will call the setter.
132
- ```
133
- Neo.create(MyTabContainer2, {
134
- activeIndex: 2
135
- });
136
- ```
137
- This will also call the setter **once**, this time using the value of 2
138
- (initConfig does merge the prototype config object with the one you pass into Neo.create -> the constructor)
139
-
140
- (3.2.) Reducing boiler plate code. When looking back at the first TabContainer example you will probably think:
141
- Damn, in case I want to define many properties via get&set which all just save&get their value inside an undercored
142
- version of its name key, this will create quite some overhead.
143
-
144
- To avoid this and make your code more beautiful, we added a trailing underscore for class configs:
145
- ```
146
- class TabContainer extends Container {
147
- static getConfig() {return {
148
- activeIndex_: 0
149
- }}
150
- }
151
- ```
152
- Look close: activeIndex<span style="color:red;font-size:200%;">_</span> .This gets you the exact same result as the previous example:
153
- ```
154
- class TabContainer extends Container {
155
- get activeIndex() {
156
- return this._activeIndex || 0;
157
- }
158
- set activeIndex(value) {
159
- this._activeIndex = value;
160
- }
161
- }
162
- ```
163
- Even better, this also **optionally** gives you support for 3 more methods you can use:
164
- ```
165
- class TabContainer extends Container {
166
- static getConfig() {return {
167
- activeIndex_: 0
168
- }}
169
-
170
- beforeSetActiveIndex(value, oldValue) {
171
- return 42; // the answer to Life, the Universe, and Everything
172
- }
173
-
174
- beforeGetActiveIndex(value) {
175
- return 5; // but hey, why tell anyone?
176
- }
177
-
178
- // this one would only get called in case value !== oldValue
179
- afterSetActiveIndex(value, oldValue) {
180
- // update the UI
181
- }
182
- }
183
- ```
184
- <a href="module-Neo.html#~autoGenerateGetSet">Details here</a>
185
-
186
-
187
-
@@ -1,28 +0,0 @@
1
- <div class="neo-header-text-container">
2
- <span class="neo-header-text">Tutorial: Component Lifecycle</span>
3
- </div>
4
- <article>
5
- <ol>
6
- <li>constructor</li>
7
- <li>onConstructed</li>
8
- <li>init</li>
9
- <li>render</li>
10
- <li>mount</li>
11
- <li>addDomListeners</li>
12
- <li>destroy [optional]</li>
13
- </ol>
14
- <p>(1) Since constructors of ES6 classes may not use &quot;this&quot; before the parent call, this one does very
15
- little,
16
- except registering the new Component to the Component Manager.</p>
17
- <p>(2) onConstructed gets called after the constructor chain is done and basically the replacement for the
18
- constructor logic.</p>
19
- <p>(3) init gets called after the onConstructed chain is done and will call render in case the autoRender-config is
20
- set to true.</p>
21
- <p>(4) render will call the Vdom worker sending the vdom (markup) and getting a vnode back.
22
- Instances with children (e.g. Container -&gt; items) will delegate the sub-trees (vnodes) downwards.</p>
23
- <p>(5) mount will send the full vnode-tree of your app (containing the outerHTML) to the main thread and create the
24
- real DOM.</p>
25
- <p>(6) Since the vdom &amp; vnode should not be aware of any DOM listeners, applying DOM listeners to the real DOM
26
- happens after mount.</p>
27
- <p>(7) Destroying a Component will unregister it from the Component Manager &amp; clear the listener references</p>
28
- </article>
@@ -1,23 +0,0 @@
1
- 1. constructor
2
- 2. onConstructed
3
- 3. init
4
- 4. render
5
- 5. mount
6
- 6. addDomListeners
7
- 7. destroy [optional]
8
-
9
- (1) Since constructors of ES6 classes may not use "this" before the parent call, this one does very little,
10
- except registering the new Component to the Component Manager.
11
-
12
- (2) onConstructed gets called after the constructor chain is done and basically the replacement for the constructor logic.
13
-
14
- (3) init gets called after the onConstructed chain is done and will call render in case the autoRender-config is set to true.
15
-
16
- (4) render will call the Vdom worker sending the vdom (markup) and getting a vnode back.
17
- Instances with children (e.g. Container -> items) will delegate the sub-trees (vnodes) downwards.
18
-
19
- (5) mount will send the full vnode-tree of your app (containing the outerHTML) to the main thread and create the real DOM.
20
-
21
- (6) Since the vdom & vnode should not be aware of any DOM listeners, applying DOM listeners to the real DOM happens after mount.
22
-
23
- (7) Destroying a Component will unregister it from the Component Manager & clear the listener references