I have been trying to make a event-emitter using ES6 promises, but when the saved response is called the second time it doesn't return anything.
var z;
function test(){
return new Promise((resolve) => {
z = resolve;
});
}
test().then(()=> console.log('aaaaaaaaaaaaaaaaaaaaaaaa') )
console.log(z) // ƒ () { [native code] }
z(); // aaaaaaaaaaaaaaaaaaaaaaaa
z(); // <empty>