Repository navigation
Conversation
DataController builds its data pipeline the first time anything reads or writes data, and resolveDataStages was only called at that moment. A plugin that tapped resolveDataStages after another plugin had already read data from its own dataController tap was silently left out of the pipeline. Rebuild the pipeline whenever a stage is tapped after it was built. The data itself lives in the base LocalModel, and the PipelinedDataModel instance and its hooks are kept, so nothing written earlier is lost.
2 of 7 tasks
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
DataControllerbuilds its data pipeline lazily, the first time anything reads or writes data, and callsresolveDataStagesonly at that moment. A stage tapped after that never runs, and nothing reports it.Ordinary plugins hit this. Plugins tap
player.hooks.dataControllerin registration order, and if a plugin registered earlier reads data in its tap (to seed or check a value, say), the pipeline is built right then. A plugin registered later that tapsresolveDataStagesfrom its owndataControllertap is silently left out. Whether a data middleware runs then depends on plugin order, which the plugin adding it doesn't control.Why it's needed now
#964 adds a streaming data plugin whose middleware serves large collections from outside the data model. Without this fix, that plugin has to detect being left out and add itself another way:
Every plugin that adds a data stage would need the same workaround. With this fix, tapping
resolveDataStagesis enough, and #964 does only that. Its test "serves the collection when a plugin registered before it already read data" fails without this change.Change
When a stage is tapped after the pipeline is built,
DataControllercallsresolveDataStagesagain and passes the result toPipelinedDataModel.setMiddleware. The data lives in the baseLocalModel, and thePipelinedDataModelinstance and its hooks are kept, so nothing written earlier is lost and listeners on the model stay attached. Tapping before the pipeline is built works as before.Rebuilding calls every
resolveDataStagestap again. A tap that creates a new middleware on each call gets a fresh instance at that point; the taps incomputed-propertiesandstage-revert-datareuse theirs, so they're unaffected.The data controller architecture page now says that a late tap rebuilds the pipeline, instead of describing the stages as frozen.
Tests
data.test.ts: a stage tapped after the first read runs, data written before the tap is kept, and anonSetlistener on the model still fires after the rebuild.player.test.ts: when one plugin reads data in itsdataControllertap and a later plugin tapsresolveDataStages, the later stage runs.Two of these fail on
main. Thecore/playervitest and eslint targets pass, as do thecomputed-propertiesandstage-revert-datasuites.Change Type (required)
Indicate the type of change your pull request is:
patchminormajorN/ADoes your PR have any documentation updates?