Created
August 19, 2014 16:28
-
-
Save kuatsure/c6708e9242f4767b2f71 to your computer and use it in GitHub Desktop.
Register and Dispatch Pattern
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@App = | |
masterArray: [] | |
init: -> | |
Initializer.start() | |
@Initializer = | |
startup_functions: [] | |
register: (func) -> | |
@startup_functions.push func | |
start: -> | |
func() for func in @startup_functions | |
$ -> | |
App.init() | |
listen_for_clicks = -> | |
$('.clickable').click -> | |
console.debug 'clicked it!' | |
Initializer.register listen_for_clicks | |
started = -> | |
console.debug "We've started!" | |
Initializer.register started | |
listen_for_input = -> | |
$('.add-list').click -> | |
console.debug "before %o", App.masterArray | |
App.masterArray.push $('.add-list-input').val() | |
console.debug "after %o", App.masterArray | |
Initializer.register listen_for_input |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html class="no-js" lang="en"> | |
<head> | |
<title>aug</title> | |
<meta charset='utf-8'> | |
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | |
<meta name="viewport" content="width=device-width, initial-scale=1"> | |
<meta name="description" content="@@DESCRIPTION" /> | |
<meta name="keywords" content="@@KEYWORDS" /> | |
<link rel="stylesheet" href="styles/screen.css?today=@@DATE" /> | |
<!--[if lt IE 9]><script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script><![endif]--> | |
</head> | |
<body class="page"> | |
<button name="button" type="button" class="btn clickable push">hi</button> | |
<input type="text" name="some_name" value="" class="add-list-input"></input> | |
<button class="btn add-list push">add to list</button> | |
<script src="scripts/imports-global.js" type="text/javascript"></script> | |
<script src="scripts/@@NAME.js?today=@@DATE" type="text/javascript"></script> | |
</body> | |
</html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment