FLUID-5621: Improve distributeOptions system so that priority of different distributions can be precisely controlled

Metadata

Source
FLUID-5621
Type
Improvement
Priority
Major
Status
Closed
Resolution
Fixed
Assignee
Antranig Basman
Reporter
Antranig Basman
Created
2015-04-15T08:58:49.938-0400
Updated
2017-02-27T15:49:17.848-0500
Versions
N/A
Fixed Versions
  1. 2.0
Component
  1. Framework

Description

The old "polymorphism at a distance" system, "demands blocks", at least had a well-defined (if not entirely usable) system for arbitrating priority of different "advice" entered into the system - this was inspired by CSS's scheme for priority based on number of matching clauses in the selector.

In theory, our IoCSS based system should be an even better fit for the CSS priority scheme, but in the meantime we have gathered more experience and our thinking has moved on. With FLUID-5587, we have supplied well-defined and stable names to distributions via namespaces which will allow a more principled and flexible priority scheme, based partly on the FLUID-5506 constraint system, to be implemented. It's crucial that any creator in the system has full ability to adjust their priority to any arbitrary position relative to all previously registered (by him) creators without having to pervert their expression through schemes such as "clause duplication" which are, for example, recommended in resources such as http://csswizardry.com/2014/07/hacks-for-dealing-with-specificity/

The base scheme for distribution priority derives "fixed priorities" (that is, the equivalents of numeric priorities for FLUID-5506 listeners) based on a "topological metric" in the component tree - a distribution which has a shorter path between the source and the target takes priority over one with a longer path.

Following these, we allow relative "constraint-based" priorities (using the same syntax and implementation as FLUID-5506) to allow any distribution to choose its priority relative to any other, based on the namespace of the other distribution.

For example,

distributeOptions: {
oneDistribution: {
record ....
target ....
priority: "after:anotherDistribution"
}, {
anotherDistribution: {
record .....
target ...
}
}

shows two distributions, one of which explicitly defers to the other. Note that this priority is resolved amongst all distributions competing for the same target at a particular time, not amongst those from a particular source.

Comments

  • Antranig Basman commented 2015-04-15T09:02:11.803-0400

    A problem resulting from lack of this feature was reported in IRC at https://botbot.me/freenode/fluid-work/2015-04-13/?msg=36502682&page=1 . Note that whilst the new "contextAwareness" scheme would allow this problem to be solved, it is a little heavyweight for the situation described in the channel, where one merely had a tooltip in a particular context that required some custom styling.

  • Antranig Basman commented 2015-08-20T14:00:27.561-0400

    Merged into trunk at revision 282f1a318718eed0b0ec060fb8b4ad254417fd7e