Last active
August 19, 2019 09:43
-
-
Save djleonskennedy/5c2c6025ba9a79d387d5ea3b98a6db02 to your computer and use it in GitHub Desktop.
demo to show, how to use Zone Js
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' | |
import {Subject} from 'rxjs'; | |
const render = new Subject(); | |
const input = document.querySelector('#input') as HTMLInputElement; | |
Zone.current.fork({ | |
name: 'my first cool zone', | |
onInvokeTask(parentZoneDelegate, _, targetZone, task, applyThis, applyArgs) { | |
render.next(input.value) | |
return parentZoneDelegate.invokeTask(targetZone, task, applyThis, applyArgs); | |
} | |
}).run(() => { | |
console.clear() | |
input.addEventListener('input', () => { | |
console.count('inputing...') | |
}) | |
setTimeout(() => console.log('inital render')) | |
}) | |
const appDiv: HTMLElement = document.getElementById('app'); | |
render.asObservable() | |
.subscribe(v => appDiv.innerHTML = `<h1>Types: ${v}</h1>`); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment