Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Configuring Root zone #513

Closed
Closed
@hmdhk

Description

@hmdhk

Is there a way to configure onScheduleTask and onInvokeTask on the root zone?
Or other interceptions for that matter?

Activity

added a commit that references this issue on Nov 25, 2016
bc2d28b
JiaLiPassion

JiaLiPassion commented on Nov 25, 2016

@JiaLiPassion
Collaborator

I don't know why zone was designed to not have a rootZoneSpec, but in my understanding, if there is a rootZoneSpec just like your PR #521, everybody can modify the rootZoneSpec so the whole system may have unstable behavior.

for example,

you app have 2 modules,
moduleA will set rootZoneSpec.onHandleError to output log, moduleB will set rootZoneSpec.onHandleError to do other stuffs. That will cause the system in a unpredictable state.
I think it's the one reason that why we can't access zoneSpec at any time, the zoneSpec's behavior (ZoneDelegate's callback) can be only defined when we create the zoneSpec.

hmdhk

hmdhk commented on Nov 27, 2016

@hmdhk
ContributorAuthor

I think this feature expands zone.js' use cases, like this one #422 ,
In my case I need to be notified about every event for performance analysis, and I can't run the whole page inside a zone.

Also, even without this change there's the possibility of monkey patching root zone, (or even monkey patching browser api directly for that matter).

In regards to going into an unpredictable state, I think different modules can modify browser API however they want. I don't think this feature provides more than what is already possible in browsers.

JiaLiPassion

JiaLiPassion commented on Nov 28, 2016

@JiaLiPassion
Collaborator

yeah, I agree with you, in fact , I need such kind of feature too. I have a suggestion that should we remove rootZoneSpec from global after the rootZone has been created?

In your PR, the code like this, after rootZone created, delete it from global so no other code can access it from outside expect who created it.

 const symbolRootZoneSpec = '__rootZoneSpec__'
 var rootZone: Zone = new Zone(null, null);
 if (global[symbolRootZoneSpec]) {
   rootZone = <Zone>rootZone.fork(global[symbolRootZoneSpec]);
   delete global[symbolRootZoneSpec];
 }
 +
hmdhk

hmdhk commented on Nov 28, 2016

@hmdhk
ContributorAuthor

@JiaLiPassion , Good call 👍 , Done.

added a commit that references this issue on Dec 6, 2016
c2b961b
mhevery

mhevery commented on Dec 18, 2016

@mhevery
Contributor

Sorry, but this is by design. RootZone should be indistinguishable for no zone at all. This requirement is here so that if we standardize the Zones in TC39, the browser vendors will not have to pay the cost for all of the applications. All zones must be entered explicitly.

added 2 commits that reference this issue on Dec 29, 2016
5290173
f4dd012
added a commit that references this issue on Feb 23, 2018
added a commit that references this issue on Feb 23, 2018

1 remaining item

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @mhevery@JiaLiPassion@hmdhk

      Issue actions

        Configuring Root zone · Issue #513 · angular/zone.js