Skip to content

Instantly share code, notes, and snippets.

View supahgreg's full-sized avatar

Greg supahgreg

  • United States
View GitHub Profile

#MVVM For JavaScript Developers

MVVM (Model View ViewModel) is an architectural pattern based on MVC and MVP, which attempts to more clearly separate the development of user-interfaces (UI) from that of the business logic and behaviour in an application. To this end, many implementations of this pattern make use of declarative data bindings to allow a separation of work on Views from other layers.

This facilitates UI and development work occurring almost simultaneously within the same codebase. UI developers write bindings to the ViewModel within their document markup (HTML), where the Model and ViewModel are maintained by developers working on the logic for the application.

##History

MVVM was originally defined by Microsoft for use with Windows Presentation Foundation (WPF) and Silverlight, having been officially announced in 2005 by John Grossman in a blog p

@supahgreg
supahgreg / codereview.md
Created August 25, 2011 15:46 — forked from addyosmani/codereview.md
Lessons from a JavaScript code review

#Lessons From A JavaScript Code Review

I was recently asked to review some code and thought I might share some of the feedback I provided as it includes a mention of JavaScript fundamentals that are always useful to bear in mind.

####Problem: Functions to be used as callbacks (as well as objects) are passed as parameters to other functions without any type validation.

Feedback: For functions, at minimum 1) test to ensure the callback exists and 2) do a typeof check to avoid issues with the app attempting to execute input which may not in fact be a valid function at all.

if (callback && typeof(callback) === "function"){
@supahgreg
supahgreg / githubYourForkSwitcher.user.js
Created July 16, 2011 14:25 — forked from erikvold/githubYourForkSwitcher.user.js
This userscript will make the ux of switching from your fork to the parent project much better, because you won't be taken to the root of the project when you switch, but instead you will be taken to the same page on the other repo.
// ==UserScript==
// @name GitHub Your Fork Switcher
// @namespace githubYourForkSwitcher
// @include http*://github.com/*/*
// @datecreated 2010-06-02
// @lastupdated 2011-07-16
// @version 0.3
// @author Erik Vergobbi Vold
// @contributor Greg Parris
// @license GPL version 3 or any later version; http://www.gnu.org/copyleft/gpl.html