Created
August 1, 2019 07:39
-
-
Save seokju-na/53bcf90081806e255d21f70036e78ce0 to your computer and use it in GitHub Desktop.
This file contains 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
import 'zone.js/dist/zone'; | |
const loadZone = Zone.current.fork({ | |
name: "seokju zone", | |
onScheduleTask(parent, current, target, task) { | |
console.log('Schedule ' + task.source, task); | |
parent.scheduleTask(target, task); | |
}, | |
onInvokeTask(parent, current, target, task) { | |
console.log('Invoking ' + task.source, task); | |
parent.invokeTask(target, task); | |
}, | |
onHasTask(parent, current, target, hasTask) { | |
if (hasTask.macroTask) { | |
console.log("MacroTask 존재"); | |
} else { | |
console.log("모든 MacroTask 끝남"); | |
} | |
} | |
}); | |
window.onload = loadZone.wrap(e => { | |
// (1) | |
fetch("http://localhost:3000/banking/products").then(res => { | |
// (2) | |
return processBody(res).then(data => { | |
// (5) | |
const dialog = document.createElement('dialog'); | |
dialog.innerHTML = `Here's some cool data: ${data} <button>OK, cool</button>`; | |
document.body.appendChild(dialog); | |
dialog.show(); | |
dialog.querySelector("button").onclick = () => { | |
// (6) | |
dialog.close(); | |
}; | |
}); | |
}); | |
}); | |
function processBody(res) { | |
// (3) | |
return res.text().then(text => { | |
// (4) | |
return text.slice(10) + '...'; | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment