neo.mjs 7.0.6 → 7.1.0

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 (73) hide show
  1. package/README.md +2 -2
  2. package/apps/ServiceWorker.mjs +2 -2
  3. package/apps/portal/index.html +1 -1
  4. package/apps/portal/model/Content.mjs +3 -2
  5. package/apps/portal/view/home/FooterContainer.mjs +1 -1
  6. package/apps/portal/view/home/parts/Features.mjs +5 -5
  7. package/examples/ServiceWorker.mjs +2 -2
  8. package/examples/todoList/version2/MainContainer.mjs +38 -48
  9. package/examples/todoList/version2/TodoList.mjs +6 -39
  10. package/examples/todoList/version2/TodoListModel.mjs +1 -1
  11. package/package.json +7 -7
  12. package/resources/data/deck/learnneo/pages/Welcome.md +0 -4
  13. package/resources/data/deck/learnneo/pages/guides/Forms.md +1 -0
  14. package/resources/data/deck/learnneo/pages/guides/InstanceLifecycle.md +1 -0
  15. package/resources/data/deck/learnneo/pages/guides/Layouts.md +1 -0
  16. package/resources/data/deck/learnneo/pages/guides/Mixins.md +1 -0
  17. package/resources/data/deck/learnneo/pages/guides/MultiWindow.md +1 -0
  18. package/resources/data/deck/learnneo/pages/guides/Tables.md +1 -0
  19. package/resources/data/deck/learnneo/pages/guides/events/DomEvents.md +263 -0
  20. package/resources/data/deck/learnneo/pages/{TodoList.md → tutorials/TodoList.md} +23 -33
  21. package/resources/data/deck/learnneo/tree.json +45 -48
  22. package/src/DefaultConfig.mjs +2 -2
  23. package/src/code/LivePreview.mjs +28 -1
  24. package/src/collection/Base.mjs +1 -0
  25. package/src/controller/Component.mjs +10 -10
  26. package/src/core/Observable.mjs +4 -27
  27. package/src/grid/View.mjs +82 -0
  28. package/src/list/Base.mjs +16 -0
  29. package/src/main/addon/DragDrop.mjs +3 -2
  30. package/src/manager/DomEvent.mjs +30 -18
  31. package/src/table/View.mjs +82 -0
  32. package/src/util/Function.mjs +24 -0
  33. package/resources/data/deck/learnneo/pages/2023-10-08T20-37-30-658Z.md +0 -0
  34. package/resources/data/deck/learnneo/pages/2023-10-08T22-22-11-013Z.md +0 -0
  35. package/resources/data/deck/learnneo/pages/Earthquakes-01-goals.md +0 -32
  36. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-01-generate-a-workspace.md +0 -47
  37. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-02-generate-the-starter-app.md +0 -150
  38. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-03-debugging.md +0 -136
  39. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-04-fetch-data.md +0 -146
  40. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-05-refactor-the-table.md +0 -146
  41. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-06-use-a-view-model.md +0 -301
  42. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-07-use-the-google-maps-addon.md +0 -175
  43. package/resources/data/deck/learnneo/pages/Earthquakes-Lab-08-events.md +0 -38
  44. package/resources/data/deck/learnneo/pages/TestLivePreview.md +0 -32
  45. package/resources/data/deck/learnneo/pages/WhatAboutHTML.md +0 -1
  46. package/resources/data/deck/learnneo/pages/stylesheet.md +0 -57
  47. /package/resources/data/deck/learnneo/pages/{WhyNeo-Effort.md → benefits/Effort.md} +0 -0
  48. /package/resources/data/deck/learnneo/pages/{WhyNeo-Features.md → benefits/Features.md} +0 -0
  49. /package/resources/data/deck/learnneo/pages/{WhyNeo-Intro.md → benefits/Introduction.md} +0 -0
  50. /package/resources/data/deck/learnneo/pages/{WhyNeo-Multi-Window.md → benefits/Multi-Window.md} +0 -0
  51. /package/resources/data/deck/learnneo/pages/{WhyNeo-Quick.md → benefits/Quick.md} +0 -0
  52. /package/resources/data/deck/learnneo/pages/{WhyNeo-Speed.md → benefits/Speed.md} +0 -0
  53. /package/resources/data/deck/learnneo/pages/{ComponentModels.md → gettingstarted/ComponentModels.md} +0 -0
  54. /package/resources/data/deck/learnneo/pages/{Config.md → gettingstarted/Config.md} +0 -0
  55. /package/resources/data/deck/learnneo/pages/{DescribingTheUI.md → gettingstarted/DescribingTheUI.md} +0 -0
  56. /package/resources/data/deck/learnneo/pages/{Events.md → gettingstarted/Events.md} +0 -0
  57. /package/resources/data/deck/learnneo/pages/{Extending.md → gettingstarted/Extending.md} +0 -0
  58. /package/resources/data/deck/learnneo/pages/{References.md → gettingstarted/References.md} +0 -0
  59. /package/resources/data/deck/learnneo/pages/{Setup.md → gettingstarted/Setup.md} +0 -0
  60. /package/resources/data/deck/learnneo/pages/{2023-10-14T19-25-08-153Z.md → gettingstarted/Workspaces.md} +0 -0
  61. /package/resources/data/deck/learnneo/pages/{ComponentsAndContainers.md → guides/ComponentsAndContainers.md} +0 -0
  62. /package/resources/data/deck/learnneo/pages/{CustomComponents.md → guides/CustomComponents.md} +0 -0
  63. /package/resources/data/deck/learnneo/pages/{MainThreadAddonExample.md → guides/MainThreadAddonExample.md} +0 -0
  64. /package/resources/data/deck/learnneo/pages/{MainThreadAddonIntro.md → guides/MainThreadAddonIntro.md} +0 -0
  65. /package/resources/data/deck/learnneo/pages/{GuideViewModels.md → guides/ViewModels.md} +0 -0
  66. /package/resources/data/deck/learnneo/pages/{GuideEvents.md → guides/events/CustomEvents.md} +0 -0
  67. /package/resources/data/deck/learnneo/pages/{2023-10-08T20-20-37-336Z.md → javascript/ClassFeatures.md} +0 -0
  68. /package/resources/data/deck/learnneo/pages/{2023-10-07T19-18-28-517Z.md → javascript/Classes.md} +0 -0
  69. /package/resources/data/deck/learnneo/pages/{2023-10-31T13-59-37-550Z.md → javascript/NewNode.md} +0 -0
  70. /package/resources/data/deck/learnneo/pages/{2023-10-08T20-20-07-934Z.md → javascript/Overrides.md} +0 -0
  71. /package/resources/data/deck/learnneo/pages/{2023-10-08T21-58-25-809Z.md → javascript/Super.md} +0 -0
  72. /package/resources/data/deck/learnneo/pages/{Earthquakes.md → tutorials/Earthquakes.md} +0 -0
  73. /package/resources/data/deck/learnneo/pages/{RSP.md → tutorials/RSP.md} +0 -0
@@ -1,146 +0,0 @@
1
- <details>
2
- <summary>Copy the table into its own class</summary>
3
-
4
- Create a new file named `apps/earthquakes/view/earthquakes/Table.mjs` with this content.
5
-
6
- <pre data-javascript>
7
- import Base from '../../../../node_modules/neo.mjs/src/table/Container.mjs';
8
-
9
- class Table extends Base {
10
- static config = {
11
- className: 'Earthquakes.view.earthquakes.Table',
12
- ntype: 'earthquakes-table',
13
- layout: {ntype: 'vbox', align: 'stretch'},
14
- style: {width: '100%'},
15
- columns: [{
16
- dataField: "timestamp",
17
- text: "Date",
18
- renderer: (data) => data.value.toLocaleDateString(undefined, {weekday: "long", year: "numeric", month: "long", day: "numeric"}),
19
- }, {
20
- dataField: "humanReadableLocation",
21
- text: "Location",
22
- }, {
23
- dataField: "size",
24
- text: "Magnitude",
25
- align: "right",
26
- renderer: (data) => data.value.toLocaleString(),
27
- }],
28
- }
29
- }
30
-
31
- Neo.setupClass(Table);
32
-
33
- export default Table;
34
- </pre>
35
-
36
- </details>
37
-
38
- <details>
39
- <summary>Review the code</summary>
40
-
41
- - The class extends `Neo.table.Container`
42
- - It has an `ntype`, which we can use when creating an instance, or when debugging
43
- - Each column has `text` and `dataField` configs, and some have renderers
44
-
45
- </details>
46
-
47
- <details>
48
- <summary>Use the new component</summary>
49
-
50
- Edit `apps/earthquakes/view/MainView` and make these changes.
51
-
52
- - Add `import EarthquakesTable from './earthquakes/Table.mjs';`
53
- - Replace the `module: Table` with `module: EarthquakesTable`
54
- - Remove the `columns:[]` config
55
- - Leave the `store` config alone
56
-
57
- Save and refresh the browser, and your app should run as before.
58
-
59
- You can confim that the new class _is being loaded_ by using DevTools to try to open `earthquakes/Table` &mdash; if it
60
- was imported, it'll be listed.
61
-
62
- You can confirm that an instance _was created_ by using the DevTools console and searching for it via
63
-
64
- Neo.first('earthquakes-table')
65
-
66
- </details>
67
-
68
- <details>
69
- <summary>Here's the code</summary>
70
-
71
- <pre data-javascript>
72
- import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
73
- import Controller from './MainViewController.mjs';
74
- import EarthquakesTable from './earthquakes/Table.mjs';
75
- import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
76
- import ViewModel from './MainViewModel.mjs';
77
-
78
- class MainView extends Base {
79
- static config = {
80
- className: 'Earthquakes.view.MainView',
81
- ntype: 'earthquakes-main',
82
-
83
- controller: {module: Controller},
84
- model: {module: ViewModel},
85
-
86
- layout: {ntype: 'vbox', align: 'stretch'},
87
- items: [{
88
- module: EarthquakesTable,
89
- store: {
90
- module: Store,
91
- model: {
92
- fields: [{
93
- name: "humanReadableLocation",
94
- }, {
95
- name: "size",
96
- }, {
97
- name: "timestamp",
98
- type: "Date",
99
- }],
100
- },
101
- url: "https://apis.is/earthquake/is",
102
- responseRoot: "results",
103
- autoLoad: true,
104
- },
105
- style: {width: '100%'},
106
- }],
107
- }
108
- }
109
-
110
- Neo.setupClass(MainView);
111
-
112
- export default MainView;
113
- </pre>
114
-
115
- </details>
116
-
117
- <details>
118
- <summary>Why are some things in `MainView` and not in `Table`?</summary>
119
-
120
- When we refactored the table into its own class we didn't move all the configs. Both
121
- the width styling and `store` were left in `MainView`. Why?
122
-
123
- It's a matter of re-use and what you need in a given situation. By leaving the width specification
124
- outside the table class we're to specify a different value in all the places we're using the table.
125
-
126
- Similarly, if the store were in the table class, it would be using that specific store and
127
- each instance of the table would have its own instance of the store. If we want multiple
128
- instance of the table with each using a different store &mdash; or if
129
- we wanted to share the store with other components &mdash; then it makes sense for the
130
- store to be outside the table class.
131
-
132
- </details>
133
-
134
- <details>
135
- <summary>Make a second instance of the table</summary>
136
-
137
- To further illustrate that the table is reusable, let's create a second instance.
138
-
139
- Simply copy-and-paste the value in the `MainView` `items` with an identical second item.
140
-
141
- Save and refresh and you should see two tables.
142
-
143
- <img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/EarthquakesTwoTables.png"></img>
144
-
145
- </details>
146
-
@@ -1,146 +0,0 @@
1
- <details>
2
- <summary>Copy the table into its own class</summary>
3
-
4
- Create a new file named `apps/earthquakes/view/earthquakes/Table.mjs` with this content.
5
-
6
- <pre data-javascript>
7
- import Base from '../../../../node_modules/neo.mjs/src/table/Container.mjs';
8
-
9
- class Table extends Base {
10
- static config = {
11
- className: 'Earthquakes.view.earthquakes.Table',
12
- ntype: 'earthquakes-table',
13
- layout: {ntype: 'vbox', align: 'stretch'},
14
- style: {width: '100%'},
15
- columns: [{
16
- dataField: "timestamp",
17
- text: "Date",
18
- renderer: (data) => data.value.toLocaleDateString(undefined, {weekday: "long", year: "numeric", month: "long", day: "numeric"}),
19
- }, {
20
- dataField: "humanReadableLocation",
21
- text: "Location",
22
- }, {
23
- dataField: "size",
24
- text: "Magnitude",
25
- align: "right",
26
- renderer: (data) => data.value.toLocaleString(),
27
- }],
28
- }
29
- }
30
-
31
- Neo.setupClass(Table);
32
-
33
- export default Table;
34
- </pre>
35
-
36
- </details>
37
-
38
- <details>
39
- <summary>Review the code</summary>
40
-
41
- - The class extends `Neo.table.Container`
42
- - It has an `ntype`, which we can use when creating an instance, or when debugging
43
- - Each column has `text` and `dataField` configs, and some have renderers
44
-
45
- </details>
46
-
47
- <details>
48
- <summary>Use the new component</summary>
49
-
50
- Edit `apps/earthquakes/view/MainView` and make these changes.
51
-
52
- - Add `import EarthquakesTable from './earthquakes/Table.mjs';`
53
- - Replace the `module: Table` with `module: EarthquakesTable`
54
- - Remove the `columns:[]` config
55
- - Leave the `store` config alone
56
-
57
- Save and refresh the browser, and your app should run as before.
58
-
59
- You can confim that the new class _is being loaded_ by using DevTools to try to open `earthquakes/Table` &mdash; if it
60
- was imported, it'll be listed.
61
-
62
- You can confirm that an instance _was created_ by using the DevTools console and searching for it via
63
-
64
- Neo.first('earthquakes-table')
65
-
66
- </details>
67
-
68
- <details>
69
- <summary>Here's the code</summary>
70
-
71
- <pre data-javascript>
72
- import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
73
- import Controller from './MainViewController.mjs';
74
- import EarthquakesTable from './earthquakes/Table.mjs';
75
- import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
76
- import ViewModel from './MainViewModel.mjs';
77
-
78
- class MainView extends Base {
79
- static config = {
80
- className: 'Earthquakes.view.MainView',
81
- ntype: 'earthquakes-main',
82
-
83
- controller: {module: Controller},
84
- model: {module: ViewModel},
85
-
86
- layout: {ntype: 'vbox', align: 'stretch'},
87
- items: [{
88
- module: EarthquakesTable,
89
- store: {
90
- module: Store,
91
- model: {
92
- fields: [{
93
- name: "humanReadableLocation",
94
- }, {
95
- name: "size",
96
- }, {
97
- name: "timestamp",
98
- type: "Date",
99
- }],
100
- },
101
- url: "https://apis.is/earthquake/is",
102
- responseRoot: "results",
103
- autoLoad: true,
104
- },
105
- style: {width: '100%'},
106
- }],
107
- }
108
- }
109
-
110
- Neo.setupClass(MainView);
111
-
112
- export default MainView;
113
- </pre>
114
-
115
- </details>
116
-
117
- <details>
118
- <summary>Why are some things in `MainView` and not in `Table`?</summary>
119
-
120
- When we refactored the table into its own class we didn't move all the configs. Both
121
- the width styling and `store` were left in `MainView`. Why?
122
-
123
- It's a matter of re-use and what you need in a given situation. By leaving the width specification
124
- outside the table class we're free to specify a different value the various places we might be using the table.
125
-
126
- Similarly, if the store were in the table class, it would be using that specific store and
127
- each instance of the table would have its own instance of the store. If we want multiple
128
- instance of the table with each using a different store &mdash; or if
129
- we wanted to share the store with other components &mdash; then it makes sense for the
130
- store to be outside the table class.
131
-
132
- </details>
133
-
134
- <details>
135
- <summary>Make a second instance of the table</summary>
136
-
137
- To further illustrate that the table is reusable, let's create a second instance.
138
-
139
- Simply copy-and-paste the value in the `MainView` `items` with an identical second item.
140
-
141
- Save and refresh and you should see two tables.
142
-
143
- <img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/EarthquakesTwoTables.png"></img>
144
-
145
- </details>
146
-
@@ -1,301 +0,0 @@
1
- <details>
2
- <summary>Look at network traffic</summary>
3
-
4
- Before making any changes, open devtools in the Network tab and refresh _earthquakes_. You'll see two
5
- calls to the web service.
6
-
7
- <img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/EarthquakesTwoTablesTwoCalls.png"></img>
8
-
9
- </details>
10
-
11
- <details>
12
- <summary>Copy the store config to the view model</summary>
13
-
14
- View models have two key configs: `data` and `stores`.
15
-
16
- - `data` holds name/value pairs where the value can be a simple value, or object references
17
- - `stores` holds configs of stores
18
-
19
- Add a `stores` property to the view model config that holds a copy of the store.
20
-
21
- <pre data-javascript>
22
- import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
23
- import Controller from './MainViewController.mjs';
24
- import EarthquakesTable from './earthquakes/Table.mjs';
25
- import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
26
- import ViewModel from './MainViewModel.mjs';
27
-
28
- class MainView extends Base {
29
- static config = {
30
- className: 'Earthquakes.view.MainView',
31
- ntype: 'earthquakes-main',
32
-
33
- controller: {module: Controller},
34
- model: {
35
- module: ViewModel,
36
- stores: {
37
- earthquakes: {
38
- module: Store,
39
- model: {
40
- fields: [{
41
- name: "humanReadableLocation"
42
- }, {
43
- name: "size"
44
- }, {
45
- name: "timestamp",
46
- type: "Date"
47
- }]
48
- },
49
- url: "https://apis.is/earthquake/is",
50
- responseRoot: "results",
51
- autoLoad: true
52
- },
53
- }
54
- },
55
-
56
- layout: {
57
- ntype: 'vbox', align: 'stretch'
58
- },
59
- items: [{
60
- module: EarthquakesTable,
61
- store: {
62
- module: Store,
63
- model: {
64
- fields: [{
65
- name: "humanReadableLocation"
66
- }, {
67
- name: "size"
68
- }, {
69
- name: "timestamp",
70
- type: "Date"
71
- }]
72
- },
73
- url: "https://apis.is/earthquake/is",
74
- responseRoot: "results",
75
- autoLoad: true
76
- },
77
- style: {width: '100%'}
78
- },{
79
- module: EarthquakesTable,
80
- store: {
81
- module: Store,
82
- model: {
83
- fields: [{
84
- name: "humanReadableLocation"
85
- }, {
86
- name: "size"
87
- }, {
88
- name: "timestamp",
89
- type: "Date"
90
- }]
91
- },
92
- url: "https://apis.is/earthquake/is",
93
- responseRoot: "results",
94
- autoLoad: true
95
- },
96
- style: {width: '100%'}
97
- }],
98
- }
99
- }
100
-
101
- Neo.setupClass(MainView);
102
-
103
- export default MainView;
104
-
105
- </pre>
106
-
107
- In the `stores` config we named the store _earthquakes_. We could have named it anything, like _foo_
108
- or _myStore_. We're calling it _earthquakes_ simply because that seems like a good descriptive name
109
- of the data the store holds.
110
-
111
- At this point we have _three_ identical store configs! Save and refresh, and look at network traffic &mdash; you
112
- should see three calls.
113
-
114
- Having an instance in the view model means we can share it. It can be shared anywhere in the containment
115
- hierarchy. The app doesn't have much of a hierarchy: it's just the main view and two child components (the two
116
- tables). But now that the store is in the parent's view model we can share it.
117
-
118
- </details>
119
-
120
- <details>
121
- <summary>Use the shared store</summary>
122
-
123
- The way to bind an instance to a view model property is with the `bind` config. For example
124
-
125
- bind: {
126
- store: 'stores.earthquakes'
127
- }
128
-
129
- binds a `store` property to a store called `foo`. The code is saying _in the future, when the value
130
- of "stores.earthquakes" changes, assign it to this object's "store" property_. In this case, `stores.earthquakes`
131
- starts out undefined, then at runtime within a few milliseconds as the view model is processed, the configured
132
- store is created and a reference is assigned to `stores.earthquakes`. That wakes the binding up, and the
133
- value is assigned to the table's `store` property.
134
-
135
- Replace each table's `store` config with the binding.
136
-
137
- <pre data-javascript>
138
-
139
- import Base from '../../../node_modules/neo.mjs/src/container/Base.mjs';
140
- import Controller from './MainViewController.mjs';
141
- import EarthquakesTable from './earthquakes/Table.mjs';
142
- import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
143
- import ViewModel from './MainViewModel.mjs';
144
-
145
- class MainView extends Base {
146
- static config = {
147
- className: 'Earthquakes.view.MainView',
148
- ntype: 'earthquakes-main',
149
- controller: {module: Controller},
150
- model: {
151
- module: ViewModel,
152
- stores: {
153
- earthquakes: {
154
- module: Store,
155
- model: {
156
- fields: [{
157
- name: "humanReadableLocation"
158
- }, {
159
- name: "size"
160
- }, {
161
- name: "timestamp",
162
- type: "Date"
163
- }]
164
- },
165
- url: "https://apis.is/earthquake/is",
166
- responseRoot: "results",
167
- autoLoad: true
168
- },
169
- }
170
- },
171
-
172
- layout: { ntype: 'vbox', align: 'stretch' },
173
- items: [{
174
- module: EarthquakesTable,
175
- bind: {
176
- store: 'stores.earthquakes'
177
- },
178
- style: {width: '100%'}
179
- },{
180
- module: EarthquakesTable,
181
- bind: {
182
- store: 'stores.earthquakes'
183
- },
184
- style: {width: '100%'}
185
- }],
186
- }
187
- }
188
-
189
- Neo.setupClass(MainView);
190
-
191
- export default MainView;
192
- </pre>
193
-
194
- Save, refresh, and look at network traffic: you'll see a _single_ call to the web service.
195
-
196
- <img style="width:80%" src="https://s3.amazonaws.com/mjs.neo.learning.images/earthquakes/EarthquakesTwoTablesOneCall.png"></img>
197
-
198
- You can further prove we're using a shared instance by running these statements in the console.
199
-
200
- <pre data-javascript>
201
- a = Neo.findFirst({ntype:'earthquakes-main'}).model.stores.earthquakes;
202
- b = Neo.find({ntype:'earthquakes-table'})[0].store;
203
- c = Neo.find({ntype:'earthquakes-table'})[1].store;
204
-
205
- (a === b) && (a === c) && (b === c) // true
206
- </pre>
207
-
208
- </details>
209
-
210
- <details>
211
- <summary>Use the view model class</summary>
212
-
213
- We configured the view model in-line, in the `model` config at the top of `MainView`. But the starter app
214
- has a `MainViewModel` class. In theory, if you have a trivial view model you could configure it in-line. But
215
- in general you want to keep that code separate by coding it in a separate class. This is what we did for the
216
- table config &mdash; we started by coding it in-line in the main view, then we refactored it into its own
217
- class. The result was a simpler and more abstract main view. We want to do the same for the view model.
218
-
219
- Since the starter app already provides `MainViewModel`, all we need to do is copy the `stores` property.
220
-
221
- Here's the resulting code you should place into `MainViewModel.mjs`.
222
-
223
- <pre data-javascript>
224
- import Model from '../../../node_modules/neo.mjs/src/model/Component.mjs';
225
- import Store from '../../../node_modules/neo.mjs/src/data/Store.mjs';
226
-
227
- class MainViewModel extends Model {
228
- static config = {
229
- className: 'Earthquakes.view.MainViewModel',
230
-
231
- data: {},
232
- stores: {
233
- earthquakes: {
234
- module: Store,
235
- model: {
236
- fields: [{
237
- name: "humanReadableLocation"
238
- }, {
239
- name: "size"
240
- }, {
241
- name: "timestamp",
242
- type: "Date"
243
- }]
244
- },
245
- url: "https://apis.is/earthquake/is",
246
- responseRoot: "results",
247
- autoLoad: true
248
- },
249
- }
250
- }
251
- }
252
-
253
- Neo.setupClass(MainViewModel);
254
-
255
- export default MainViewModel;
256
- </pre>
257
-
258
- And you need to remove the `stores` config from the main view as follows.
259
-
260
- <pre data-javascript>
261
- import Container from '../../../node_modules/neo.mjs/src/container/Base.mjs';
262
- import Controller from './MainViewController.mjs';
263
- import EarthquakesTable from './earthquakes/Table.mjs';
264
- import ViewModel from './MainViewModel.mjs';
265
-
266
- class MainView extends Container {
267
- static config = {
268
- className: 'Earthquakes.view.MainView',
269
- ntype: 'earthquakes-main',
270
- controller: {module: Controller},
271
- model: {
272
- module: ViewModel
273
- },
274
-
275
- layout: { ntype: 'vbox', align: 'stretch' },
276
- items: [{
277
- module: EarthquakesTable,
278
- bind: {
279
- store: 'stores.earthquakes'
280
- },
281
- style: {width: '100%'}
282
- },{
283
- module: EarthquakesTable,
284
- bind: {
285
- store: 'stores.earthquakes'
286
- },
287
- style: {width: '100%'}
288
- }]
289
- }
290
- }
291
-
292
- Neo.setupClass(MainView);
293
-
294
- export default MainView;
295
- </pre>
296
-
297
- The refactorings to have separate table and view model classes means the code is more modular, more reusable,
298
- and each class is simpler than using complex source files that try to configure every detail.
299
-
300
- </details>
301
-