data system with invalidate up, validate down paradigm

12 views
Skip to first unread message

Markus Kropf

unread,
Jun 18, 2018, 12:15:48 PM6/18/18
to Polymer
TL;DR The Polymer data system is difficult to get right. An invalidate-validate paradigm would greatly improve the situation.

It is hard to keep a component with multiple properties in a consistent state. Property changes can happen in unpredictable order. Polymer lately has introduced batched property changes to improve the situation, but while it made initializations more predictable, it introduced additional complexity by resulting in different behavior dependent on a component being attached or not.

The current data system is based on a change push principle: When a property changes, the change is pushed along dependencies to other properties and other components. This mechanism is inherently order-sensitive. Maths learns us the great power of order-insensitivity (commutativity). A data system with built-in commutativity would be much easier to handle.

Switching to an invalidate-validate paradigm would provide commutativity. It would roughly work as follows:
- any change to a component changes its internal state and marks it 'dirty'
- when a component changes from not dirty to dirty, it marks it's parent dirty, up the tree to the top
- in a later call frame, 'validate' is called recursively down the component tree
- in validate, a component updates its properties, then sends validate to all its dirty children, then clears it's dirty state

The invalidate-validate paradigm is extremely performant and very stable. It was used for decades in innumerable systems.
I would really love to get it introduced in web components someday...

Markus Kropf

unread,
Jun 18, 2018, 12:25:00 PM6/18/18
to Polymer

Brendan Baldwin

unread,
Jun 19, 2018, 2:44:05 PM6/19/18
to Polymer
Worth considering also:

Reply all
Reply to author
Forward
0 new messages