Last active
August 29, 2015 14:15
-
-
Save mamiu/00945368e8e37ecad63e to your computer and use it in GitHub Desktop.
EventEmitter sample for Lornez ;)
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
| var contactForm = function(){ | |
| EventEmitter.call(this); | |
| var submit = function(email, name, message){ | |
| this.emit("submitContactForm", email, name, message); | |
| } | |
| var validateForm = function(email, name, message){ | |
| //check if all required fields are filled and the text is valid (no attacks) | |
| this.emit("validated", email, name, message); | |
| } | |
| var sendContent = function(email, name, message){ | |
| //try to send the form content | |
| this.emit("contentSent", email, name, message); | |
| } | |
| var showInfo(){ | |
| //open dialog box with success message or replace form with thanks text^^ | |
| this.emit("submitSuccessfull", "The Content was sent successfully"); | |
| } | |
| this.on("submitContactForm", validateForm); | |
| this.on("validated", sendContent); | |
| this.on("contentSend", showInfo); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment