Streamline system initialization refactor #1629
Draft
+560
−159
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.
DRAFT pending #1589 , on which this PR builds.
Description
Refactors the initialization of streamline to an explicit call to StreamlineSystem.init. This new method is responsible for building all the singletons used by streamline, rather than putting that responsibility on the Registrar. This promotes a better separation of concerns, especially as we add more singleton-type functionality to initialize.
This also standardizes re-initialization behavior. Re-initializing an already-initialized system will simply rebuild all the singletons. While this would be wasteful if abused in production, it supports testing scenarios where multiple models may be built and re-built as tests are run.
Finally, after merging in #1589, this adds a globally-visible absolute clock, and relatedly the
StreamlineSystem.currentInstant()
method to get the current time as an Instant.Verification
Existing unit tests were updated to call StreamlineSystem.init, and they continue to function properly.
The streamline-demo model was also updated to call this method, and was tested manually in a local aerie deployment. It continues to function correctly as well.
Documentation
IMPORTANT: This is a breaking change!
All projects that use streamline should change
into
when constructing their model. This will properly initialize the full streamline system.
Additionally,
currentTime()
has moved fromResources
toStreamlineSystem
.Finally, while not a breaking change, this does expose
StreamlineSystem.currentInstant()
, which returns the current absolute time as an Instant. This is something I expect many might find useful.Future work
N/A