Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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