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
class Handler { | |
respond(e: CustomEvent): any { | |
return e.detail; // continue and provide same value (see Function Purity) | |
} | |
} | |
/** | |
* @name: The Chain of Responsibility Pattern | |
* @intention |
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
clear(); | |
/** | |
* @param : source := EventTarget | |
* * EventTarget.prototype | |
* * Node (Element, Attr, etc) | |
* @usage : [Node].addEventListener('*', ({ detail: e }) => {...}, false); | |
*/ | |
function proxyEventTargetSource(source) { | |
var emit = source.dispatchEvent; // obtain reference |
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
clear(); | |
var http = { | |
get(url) { | |
var delay = Math.floor( Math.random() * 10 ), even = !(delay % 2); | |
var xhr = new Promise(exe); | |
console.log(`REQUEST`, url, delay); | |
xhr.then( (data) => console.log(`SUCCESS: `, data) ).catch( (data) => console.log(`FAILURE: `, data) ); |