Have ideas to improve npm?Join in the discussion! »

    puremvc

    1.0.4 • Public • Published

    PureMVC for node

    Build Status

    Overview

    This is a port of puremvc for node.

    Usage

    install

    npm install puremvc

    define AppFacade

    import puremvc from 'puremvc';
    import * as controller from './controller/command';
     
    export class AppFacade extends puremvc.Facade {
       /** @override */
      initializeController() {
        super.initializeController();
        this.registerCommand(AppFacade.START, controller.StartCommand);
      }
     
      /** @override */
      initializeModel() {
        super.initializeModel();
      }
     
      /** @override */
      initializeView() {
        super.initializeView();
      }
     
      start() {
        this.sendNotification(AppFacade.START, {});
      }
     
      static getInstance(multitonKey) {
        const instanceMap = puremvc.Facade.instanceMap;
        if (!instanceMap[multitonKey]) {
          instanceMap[multitonKey] = new AppFacade(multitonKey);
        }
        return instanceMap[multitonKey];
      }
    }
     
    AppFacade.START = 'Start';
     

    defind StartCommand

    import puremvc from 'puremvc';
     
    export class StartCommand extends puremvc.SimpleCommand {
      /** @override */
      execute(notification) {
        cc.log('in start cmd');
        // register proxy
        this.facade.registerProxy(new GameProxy());
     
        // register mediator
        this.facade.registerMediator(new DirectorMediator());
      }
    }

    Keywords

    Install

    npm i puremvc

    DownloadsWeekly Downloads

    13

    Version

    1.0.4

    License

    none

    Last publish

    Collaborators

    • avatar