Description
This is a WIP; I'm still digesting the docs in this repo.
Background
I'm working on a distinct ES5 implementation of zones for browsers.
It would be nice if the semantics for both libraries are similar.
It also might be good to develop a spec so that someday JS knows how to do this without monkeypatching the universe.
This is written mostly for @piscisaureus to begin discussing the differences in our libraries.
Summary
Conceptually, there are two broad classes of uses for zones:
- You want to do something before/after all async tasks
- You want to do something once all async things are done for some context
Zone.js
Zone.js is concerned with exposing a minimal set of hooks and the ability to compose behaviors.
Zone.js has a number of optional "zones" built on top of it to provide functionality some of
the same functionality as zone
:
zone.fork(Zone.countingZone).fork({
onFlush: function () {
console.log('no pending tasks!');
}
});
zone
zone
seems concerned with solving control-flow problems, resource management, and cleanup.
Zones are like asynchronous functions. From the outside perspective, they can return a single value or "throw" a single error.
It doesn't seem likezone
has hooks for before/after tasks or for overriding functionality.
Zones
- What does it mean to enter/leave a zone?
- Do zones "begin" or "end" ?
- "shared resources" within zones.
- Zone.js allows you to attach arbitrary metadata to a zone by augmenting its properties.
zone
hasZone.data
Creating nested/child zones
- What does it mean to nest a zone?
- What should this be called? Zone.js calls this
fork
.
Gates
- TODO