Uploaded image for project: 'Fluid Infusion'
  1. Fluid Infusion
  2. FLUID-6234

Sorting of application of model values init transaction does not respect relay propagation directives

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: Major
    • Resolution: Fixed
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: Data Binder
    • Labels:
      None

      Description

      Even if the user attempts to express a preference for which components should have their initial model values take priority during the "init transaction" by using directives such as

      forward: { excludeSource: "init"}

      , the framework may sort the application times of these initial values into an ordering which leads to a final set of resolved values around the model skeleton that does not respect this preference.

      For example, this test environment taken from a branch of @colin 's Aconite project at https://github.com/colinbdclark/aconite/blob/gh-9/tests/unit/video-performer-tests.js#L19 specifies an initial value for a component which participates in a relay with two subcomponents: 

          fluid.defaults("aconite.test.videoPerformer.testEnvironment", {
              gradeNames: "fluid.test.testEnvironment",
      
              components: {
                  videoPerformer: {
                      type: "aconite.videoPerformer",
                      options: {
                          model: {
                              loop: true
                          }
                      }
                  }
      

      The subcomponents have been each set up in https://github.com/colinbdclark/aconite/blob/gh-9/src/video-performer.js with a relay directive as follows which should prevent child values from propagating up to the parent:

          fluid.defaults("aconite.videoPerformer.relayingChild", {
              gradeNames: "fluid.modelComponent",
      
              model: {},
      
              // Note: this relay is required to prevent
              // initial model values from propagating back
              // from this component up to the parent,
              // overriding the user's desired value.
              modelRelay: {
                  source: "{videoPerformer}.model",
                  target: "{that}.model",
                  backward: {
                      excludeSource: "init"
                  },
                  singleTransform: {
                      type: "fluid.transforms.identity"
                  }
              }
          });
      

      The definition does indeed stop the propagation of the child values during the init transaction, but the final resolved value across the skeleton is not the one that the user desires - during the process of resolving the init transaction, the parent's value is applied first and the children's later, leading the children to have the default value of loop: false and only the parent with the inconsistent, desired value of loop: true.

      It is finally time to bite the bullet and introduce a topological sorting algorithm that guarantees to respect such one-way directives during the init transaction - that is, the directed graph induced by such directives needs to be parsed out of the total configuration and used to induce a topological sorting order which applies "most depended-on values" last.

        Attachments

        1. aconite-init-failure.png
          294 kB
          Antranig Basman

          Activity

            People

            Assignee:
            antranig Antranig Basman
            Reporter:
            antranig Antranig Basman
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved: