Skip to content
This repository has been archived by the owner on Aug 24, 2021. It is now read-only.

ludder/tomvc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Basic ES5 implementation of MVC

Build Status

ToMvc is MVC

ToMvc provides a basic implementation of the MVC pattern in JavaScript (ES5). While views communicate with the DOM, and models interact with data objects, the controller glues them together. Views and models don't know each other. They communicate via events, controlled by the Controller class.

Controller

A controller instance controls:

  • views
  • models
  • events

Instantiation:

var controller =  new ToMvc.Controller;

View

A view is connected with a part of the DOM.

At instantation a controller instance and a DOM element el are required:

var controller =  new ToMvc.Controller;
var myView = new ToMvc.View({
    controller: controller,
    el        : 'body'
});

Model

A model is connected with data objects.

At instantation a controller instance is required:

var controller =  new ToMvc.Controller;
var myModel = new ToMvc.Model({
    controller: controller
});

Subclassing

An extend method is provided by Controllers, Views and Models to make subclassing easy.

Example:

var SubView = ToMvc.View.extend();
var mySubview = new SubView( {
    controller: new ToMvc.Controller,
    el: 'body'
} );

Development

License

BSD

About

Basic ES5 implementation of TodoMVC

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published