Coder Social home page Coder Social logo

minimvc's Introduction

minimvc

Tiny kernel Pure MVC inspired javascript prototype based pattern explorer of might, doom and peril

Usage

1. init the kernel

var mvc = new MiniMVC()

2. create modules

var frontend = mvc.get('Module', 'Frontend')

var backend = mvc.get('Module', 'Backend')

3. init patterns

var controller = frontend.get('Controller')

var model = frontend.get('Model')

var view = frontend.get('View')

4. define a command

var command = controller.get('Command', 'MyCommand')

command.execute = function(note) {

console.info('Executed notification from command', note.data())

}

5. define a proxy

var proxy = model.get('Proxy', 'MyProxy')

proxy.data('key', 'value v1')

proxy.data({'key1': 'value v1', 'key2': 'value v3'})

6. define a mediator

var mediator = view.get('Mediator', 'MyMediator')

7. Create a notification(last parameter is true, this instances will not be persisted)

var notification = frontend.get('Notification', 'MyNotification', true)

8. Handle notifications inside module's patterns

controller.handle(notification).through(command)

proxy.handle(notification).through(function(note) { console.info('Executed notification from callback(proxy)', note.data()) })

mediator.handle(notification).through(function(note) { console.info('Executed notification from callback(mediator)', note.data()) })

9. Handle notification from other module

backend.handle(notification).through(function(note) { console.info('Executed notification from backend module', note.data()) })

10. Route the notification (no param, to originating module only, in this case frontend module)

notification.route()

11. Route the notification to all modules

notification.route("*")

12. Route the notification to a certain module (non originating module)

notification.route(backend.type)

13. Route the notification to some modules

notification.route(frontend.type, backend.type)

minimvc's People

Contributors

iongion avatar

Stargazers

 avatar  avatar

Watchers

 avatar

Forkers

caracal7 sahwar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.