Skip to content

Instantly share code, notes, and snippets.

@djleonskennedy
Last active August 19, 2019 09:43
Show Gist options
  • Save djleonskennedy/5c2c6025ba9a79d387d5ea3b98a6db02 to your computer and use it in GitHub Desktop.
Save djleonskennedy/5c2c6025ba9a79d387d5ea3b98a6db02 to your computer and use it in GitHub Desktop.
demo to show, how to use Zone Js
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