0.0.43 • Published 2 years ago
@sndcds/mvc v0.0.43
mvc
Experimental Generative MVC Library.
Install
pnpm install @sndcds/mvc
Examples
https://github.com/sndcds/mvc-example
Basic functionality
- Create one or more views related to
<div>
elements in your HTML using their id attributes. - Create components in a tree hierarchy.
- Send messages to views and components.
Features
- Components are aware of their parent and child components.
- Components can define custom logic to handle messages.
Example
const model = new AppModel()
const view = new View()
const containerA = new Component(view, 'containerA')
const containerB = new Component(view, 'containerB')
const containerC = new Component(view, 'containerC')
new Component(containerA, 'button1')
new Component(containerB, 'button2')
new Component(containerB, 'button3')
for (let i = 0; i < 9; i++) {
new TestComponent(containerC, `component-${i}`)
}
const app = new App(model, view)
app.init('./details.json', 1)
app.buildView('root')
app.sendMessage("Hello Component")
app.sendMessageToComponent('button3', "News")
app.setProperties('component-4', {"color": "#048", "width": 100, "flag": true })
app.setProperties('component-6', {"color": "#965", "width": 100, "flag": true })
app.setProperties('component-987', {"color": "#a93", "width": 100, "flag": true })
const c = app.componentById('component-3')
console.log(c.id)
0.0.43
2 years ago
0.0.41
2 years ago
0.0.39
2 years ago
0.0.38
2 years ago
0.0.37
2 years ago
0.0.33
2 years ago
0.0.31
2 years ago
0.0.29
2 years ago
0.0.28
2 years ago
0.0.27
2 years ago
0.0.26
2 years ago
0.0.25
2 years ago
0.0.24
2 years ago
0.0.23
2 years ago
0.0.22
2 years ago
0.0.20
2 years ago
0.0.19
2 years ago
0.0.18
2 years ago
0.0.17
2 years ago
0.0.16
2 years ago
0.0.15
2 years ago
0.0.14
2 years ago
0.0.13
2 years ago
0.0.12
2 years ago
0.0.11
2 years ago
0.0.10
2 years ago
0.0.9
2 years ago
0.0.8
2 years ago
0.0.7
2 years ago
0.0.6
2 years ago
0.0.5
2 years ago
0.0.4
2 years ago
0.0.3
2 years ago
0.0.2
2 years ago
0.0.1
2 years ago