Discussion:
[dart-misc] Zones and Cusomt Elements
'Justin Fagnani' via Dart Misc
2015-09-12 11:16:18 UTC
Permalink
Is there any documentation on how Zones and custom elements interact?

The lifecycle methods of custom elements are called by the browser, and I
assume (or hope) they are called in whatever zone was current when the
element was registered, but nothing says so.

I'm also interested in installing specific zones for each lifecycle
callback, but don't see anyway to do that. In JavaScript I can just replace
the lifecycle callbacks with ones bound to the zone I've created, but I of
course can't do this in Dart.

Thanks!
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'John Messerly' via Dart Misc
2015-09-14 01:12:10 UTC
Permalink
On Sat, Sep 12, 2015 at 4:16 AM, 'Justin Fagnani' via Dart Misc <
Post by 'Justin Fagnani' via Dart Misc
Is there any documentation on how Zones and custom elements interact?
It probably uses the root zone. I doubt we hooked it up to make zoned
calls. Even if we did, it likely wouldn't work when we're polyfilling
because of: https://github.com/dart-lang/sdk/issues/17301

The lifecycle methods of custom elements are called by the browser, and I
Post by 'Justin Fagnani' via Dart Misc
assume (or hope) they are called in whatever zone was current when the
element was registered, but nothing says so.
I'm also interested in installing specific zones for each lifecycle
callback, but don't see anyway to do that. In JavaScript I can just replace
the lifecycle callbacks with ones bound to the zone I've created, but I of
course can't do this in Dart.
you'd have to enter the zone explicitly, something like:


attached() {
myZone.run(() {
...
});
}
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'John Messerly' via Dart Misc
2015-09-14 01:15:36 UTC
Permalink
fwiw, it looks like this works in zone.js:
https://github.com/angular/zone.js/blob/77b4c0d2960a71207137ac006326edb6160ab13b/lib/patch/register-element.js
Post by 'John Messerly' via Dart Misc
On Sat, Sep 12, 2015 at 4:16 AM, 'Justin Fagnani' via Dart Misc <
Post by 'Justin Fagnani' via Dart Misc
Is there any documentation on how Zones and custom elements interact?
It probably uses the root zone. I doubt we hooked it up to make zoned
calls. Even if we did, it likely wouldn't work when we're polyfilling
because of: https://github.com/dart-lang/sdk/issues/17301
The lifecycle methods of custom elements are called by the browser, and I
Post by 'Justin Fagnani' via Dart Misc
assume (or hope) they are called in whatever zone was current when the
element was registered, but nothing says so.
I'm also interested in installing specific zones for each lifecycle
callback, but don't see anyway to do that. In JavaScript I can just replace
the lifecycle callbacks with ones bound to the zone I've created, but I of
course can't do this in Dart.
attached() {
myZone.run(() {
...
});
}
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
'Justin Fagnani' via Dart Misc
2015-09-14 01:23:30 UTC
Permalink
Post by 'John Messerly' via Dart Misc
On Sat, Sep 12, 2015 at 4:16 AM, 'Justin Fagnani' via Dart Misc <
Post by 'Justin Fagnani' via Dart Misc
Is there any documentation on how Zones and custom elements interact?
It probably uses the root zone. I doubt we hooked it up to make zoned
calls. Even if we did, it likely wouldn't work when we're polyfilling
because of: https://github.com/dart-lang/sdk/issues/17301

I wouldn't think that bug would be a blocker since Dart custom elements
could explicitly restore the correct Dart zone in the compiled callbacks.
Post by 'John Messerly' via Dart Misc
Post by 'Justin Fagnani' via Dart Misc
The lifecycle methods of custom elements are called by the browser, and
I assume (or hope) they are called in whatever zone was current when the
element was registered, but nothing says so.
Post by 'John Messerly' via Dart Misc
Post by 'Justin Fagnani' via Dart Misc
I'm also interested in installing specific zones for each lifecycle
callback, but don't see anyway to do that. In JavaScript I can just replace
the lifecycle callbacks with ones bound to the zone I've created, but I of
course can't do this in Dart.
Post by 'John Messerly' via Dart Misc
Post by 'Justin Fagnani' via Dart Misc
attached() {
myZone.run(() {
...
});
}
I want to do this for ask elements though. In JavaScript I just replace
registerElement with a version that replaces all the callbacks of elements
to versions bound to a zone.

In Dart there's no way to do that, so there would have to be some other
control, like a ZoneSpecification callback, at least for registerElement,
and maybe each lifecycle callback.
Post by 'John Messerly' via Dart Misc
--
For other discussions, see https://groups.google.com/a/dartlang.org/
For HOWTO questions, visit http://stackoverflow.com/tags/dart
To file a bug report or feature request, go to http://www.dartbug.com/new
To unsubscribe from this group and stop receiving emails from it, send an
email to misc+***@dartlang.org.
--
For other discussions, see https://groups.google.com/a/dartlang.org/

For HOWTO questions, visit http://stackoverflow.com/tags/dart

To file a bug report or feature request, go to http://www.dartbug.com/new

To unsubscribe from this group and stop receiving emails from it, send an email to misc+***@dartlang.org.
Loading...