|
| 1 | +## Critical Mental Model Shift for React/Vue/Angular Developers |
| 2 | + |
| 3 | +**If you're coming from React, Vue, or Angular:** Neo.mjs requires a fundamental shift in how you think about UI composition. This isn't just different syntax—it's a completely different paradigm. |
| 4 | + |
| 5 | +### What You're Used To (Other Frameworks) |
| 6 | +In React, Vue, and Angular, you compose UIs by writing templates/JSX that mix HTML elements with custom components: |
| 7 | + |
| 8 | +```jsx |
| 9 | +// React/Vue/Angular pattern - mixing HTML with components |
| 10 | +function App() { |
| 11 | + return ( |
| 12 | + <div className="viewport"> |
| 13 | + <HeaderToolbar /> |
| 14 | + <div className="main-content"> |
| 15 | + <CustomButton text="Click me" /> |
| 16 | + <DataGrid data={users} /> |
| 17 | + </div> |
| 18 | + </div> |
| 19 | + ); |
| 20 | +} |
| 21 | +``` |
| 22 | + |
| 23 | +Your mental model: *"I write the DOM structure I want, and insert components as custom HTML tags."* |
| 24 | + |
| 25 | +### What Neo.mjs Actually Does |
| 26 | +In Neo.mjs, you compose UIs through **declarative component configurations** that describe relationships: |
| 27 | + |
| 28 | +```javascript |
| 29 | +// Neo.mjs pattern - component relationship configuration |
| 30 | +class App extends Container { |
| 31 | + static config = { |
| 32 | + cls: ['viewport'], |
| 33 | + items: [{ |
| 34 | + module: HeaderToolbar |
| 35 | + }, { |
| 36 | + module: Container, |
| 37 | + cls: ['main-content'], |
| 38 | + items: [{ |
| 39 | + module: CustomButton, |
| 40 | + text: 'Click me' |
| 41 | + }, { |
| 42 | + module: DataGrid, |
| 43 | + data: users |
| 44 | + }] |
| 45 | + }] |
| 46 | + } |
| 47 | +} |
| 48 | +``` |
| 49 | + |
| 50 | +Your new mental model: *"I configure component relationships through `items`, and components define their own internal DOM structure through `vdom`."* |
| 51 | + |
| 52 | +### The Key Difference |
| 53 | +- **Other frameworks**: You write DOM structure first, then add components as tags |
| 54 | +- **Neo.mjs**: You configure component hierarchies via `items`. Individual components define their internal DOM via `vdom` |
| 55 | + |
| 56 | +### When to Use Each Approach |
| 57 | +- **Component composition via `items`** (99% of application development): Building UIs, managing hierarchies, application logic |
| 58 | +- **VDom manipulation** (1% - framework development): Creating custom components, optimizing internal component rendering |
| 59 | + |
| 60 | +--- |
| 61 | + |
1 | 62 | ## Introduction |
2 | 63 |
|
3 | 64 | Neo.mjs employs a unique two-tier architecture that separates **declarative component configuration** from **imperative virtual DOM (VDom) operations**. This design provides both developer productivity and framework performance optimization while maintaining clear separation of concerns across different abstraction layers. |
@@ -47,7 +108,7 @@ class Viewport extends BaseViewport { |
47 | 108 | - **Hierarchical**: Nested `items` arrays establish parent-child relationships. |
48 | 109 | - **Referential**: `reference` property enables component lookup. |
49 | 110 | - **Mutable Structure**: The live component instance tree is **dynamic and mutable at runtime**, allowing developers to |
50 | | - imperatively add, remove, or reorder components using methods like `add()`, `remove()` and `insert()`." |
| 111 | + imperatively add, remove, or reorder components using methods like `add()`, `remove()` and `insert()`. |
51 | 112 |
|
52 | 113 | ### State Provider Integration |
53 | 114 |
|
@@ -303,7 +364,7 @@ afterSetBadgeText(value, oldValue) { |
303 | 364 | ### For Application Development: |
304 | 365 |
|
305 | 366 | 1. **Favor Declarative**: Use component configurations over Vdom manipulation. |
306 | | - Primarily use component configurations (`items`) for building UIs. |
| 367 | + Primarily use component configurations (`items`) for building UIs. |
307 | 368 | 2. **State Management**: Leverage reactive state providers |
308 | 369 | 3. **Component Composition**: Build complex UIs through item hierarchies |
309 | 370 | 4. **Reference Usage**: Use `reference` for component communication |
|
0 commit comments