Closed jolleekin closed 8 years ago
Lifecycle callbacks are called on the element class first, then for each behavior in the order they are mixed in (left to right).
Lifecycle callbacks are called for each behavior in the order they are mixed in (left to right), then on the element class.
Console log: VM2378:1 B1.created VM2378:1 B2.created VM2378:1 B1.ready VM2378:1 B2.ready VM2378:1 MainApp.ready VM2378:1 B1.attached VM2378:1 B2.attached VM2378:1 MainApp.attached VM2378:1 MainApp.created
@behavior abstract class B1 { static const name = 'B1'; static attached(instance) { print('$name.attached'); } static created(instance) { print('$name.created'); } static ready(instance) { print('$name.ready'); } } @behavior abstract class B2 implements B1 { static const name = 'B2'; static attached(instance) { print('$name.attached'); } static created(instance) { print('$name.created'); } static ready(instance) { print('$name.ready'); } } /// Uses [PaperInput] @PolymerRegister('main-app') class MainApp extends PolymerElement with B1, B2 { static const name = 'MainApp'; @property String text; /// Constructor used to create instance of MainApp. MainApp.created() : super.created() { print('$name.created'); } attached() { print('$name.attached'); } ready() { print('$name.ready'); } @reflectable String reverseText(String text) { return text.split('').reversed.join(''); } }
Thanks for the nice repro, updated the wiki
Wiki says
Lifecycle callbacks are called on the element class first, then for each behavior in the order they are mixed in (left to right).
Runtime results
Lifecycle callbacks are called for each behavior in the order they are mixed in (left to right), then on the element class.
Console log: VM2378:1 B1.created VM2378:1 B2.created VM2378:1 B1.ready VM2378:1 B2.ready VM2378:1 MainApp.ready VM2378:1 B1.attached VM2378:1 B2.attached VM2378:1 MainApp.attached VM2378:1 MainApp.created
Code to reproduce