Skip to content

Instantly share code, notes, and snippets.

View zdying's full-sized avatar

zhang zdying

View GitHub Profile
@zdying
zdying / context.coffee
Created March 28, 2016 04:00 — forked from watert/context.coffee
Adding context for Express.js req/res cycle
# Adding context for req/res cycle for Express.js.
# With context it would be possible to write more terse code:
#
# app.use ->
# @user = {name: 'Anonymous'}
# @next()
#
# app.get '/', ->
# @res.end "Hello, #{@user.name}"
#
<!--
English:
This example show how do a simple MVVM code with html+js
You can change the data in design and the object person will be changed, you can too make the change by the console(js) of the property from the object and the visual will be changed.
Portugues:
Esse exemplo mostra como fazer um simples MVVM framework com HTML e JS
Você pode alterar os dados visualmente e o objeto pessoa vai ser alterado e também se você fizer a alteração via console da propriedade o visual será modificado.
-->
<!DOCTYPE html>
<html>
function debugAccess(obj, prop, debugGet){
var origValue = obj[prop];
Object.defineProperty(obj, prop, {
get: function () {
if ( debugGet )
debugger;
return origValue;
},