Simple framework for web development, implements a facade and mediator patterns, inspired by Aura and other work on modular js apps.
The only thing it does it abstract, without solving problems that don't yet need to be fixed, as aliasing ALL methods in Underscore, Backbone, etc. Facade should be extended on need, not by default to simplify development ( less abstraction, predictability of available methods and their behaviour ).
Event-driven communication between modules.
Each module has its api and the implementation layer proxies events between modules.
Card Menu module triggers 'cardMenu:favorite' with cardId as argument.
Card Deck module listens for 'cardDeck:favorite' and accepts cardId as argument.
Mediator will connect both modules by triggering 'cardDeck:favorite' when 'cardMenu:favorite' is triggered.
Additionally, the Mediator will listen for a 'cardDeck:favorite:success' event and trigger the 'cardMenu:hide' event.
The Card Menu provides an (event) api and so does the Card Deck, all we need to do in order for them to remain abstracted from each other of to write the minimal Glue.
The Core Touch module will fire control events such as: 'control:swipe:right', the mediator will, based on context, trigger the appropriate event. eg:
- if the Card Menu module is the currently focused module, then trigger the 'cardDeck:show' event.
- if the Card Deck module if the currently focused module, then trigger the 'cardDeck:hide' event.
Zepto -> Native methods map ( only the relevant methods listed )
.find - document.[ querySelector | querySelectorAll ] removeClass - el.classList.remove addClass - el.classList.add text - el.textContent html - el.( innerHTML | outerHTML ) append - el.appendChild prepend - el.appendChild( node )
on - el.addEventListener trigger - el.dispatchEvent
data - el.dataset