@@ -5,6 +5,13 @@ import View from './view';
55import Provider from './provider' ;
66import CopyPaste from './copypaste' ;
77
8+ /**
9+ * Controller which acts as business logic between models, views and
10+ * providers. In general, create a new controller using the New
11+ * static method and then define properties of the controller. Call
12+ * main to run the application.
13+ * @class
14+ */
815export default class Controller {
916 constructor ( ) {
1017 this . $providers = new Map ( ) ;
@@ -28,7 +35,13 @@ export default class Controller {
2835 } ) ;
2936 }
3037
31- Add ( key , object ) {
38+ /**
39+ * Define a view or provider for the controller. The object is then
40+ * accessible as a property of the controller.
41+ * @param {string } key - The name of the property
42+ * @param {Provider|View } object - The object
43+ */
44+ define ( key , object ) {
3245 if ( ! key || this . $providers . has ( key ) || this . $views . has ( key ) ) {
3346 throw Error ( `Controller: Duplicate or invalid key ${ key } ` ) ;
3447 }
@@ -47,6 +60,10 @@ export default class Controller {
4760 } ) ;
4861 }
4962
63+ /**
64+ * Create and return a new controller
65+ * @param {Controller } constructor - The constructor for the controller
66+ */
5067 static New ( constructor ) {
5168 const C = constructor || Controller ;
5269 if ( C . prototype instanceof Controller ) {
0 commit comments