Centralizing data conversion and storage #461
Closed
PaulBredl
announced in
Refactorings
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
The modularity of our code could be improved.
Especially the
AceEditor
and thePropertiesPanel
are quite big files.Issues
We should implement a central
DataManager
that is responsible for those operations.But other components also should have access to the raw, unparsed data, e.g. the toolbar.
We should move the data convertion and simultaniously make it easier to extend the tool with other data formats.
Proposed design
The following components should be added/adapted:
Central data format registry
We implement a registry for all data formats that provides tha following interface:
getFormat(name: string): DataFormat
: Returns a registered data formatregisterFormat(name: string, format: DataFormat
: Registeres a new data formatInternally, this registry would use a simple Map
DataFormat interface
dataConverter(): DataConverter
returns the data converter (see below), mandatory,pathCursorPositionLink(): PathCursorPositionLink() | null
returns the linkage logic to map from a path to a cursor position and vice versa. Can be ommited, but will make the tool less effective with that format.DataConverter
Parse and stringify data, with utility methods.
useDataConverter()
: Static accessor to the converter of the current data format.PathCursorPositionLink
See current ConfigManipulator for methods (except parsing and stringifying)
usePathCursorPositionLink()
Static accessor to the link of the current data formatDataStore
The data store should be modified in the followings ways:
shallowRef
refs
to objects, and thereby make it intransparent that the data is acutally aref
. We also had some issues in the past where refs from pinia would not trigger watches as expectedDataLink
The data link interface will basically be the tripple (data, data as raw string, schema of data), with the following properties:
SchemaPreprocessor
The schema preprocessor should become a composable or a class that is resposible for preprocessing raw schema data.
It should expose:
JsonSchema
class could be renamed toGuiOptimizedJsonSchema
DataManager (or potentially DataAndSchemaManager)
The class that will be responsible for accessing and modifying the data in the components of the tool.
Dependencies:
DataLink
. This will be switched when changing the page / current modebasePath
(?), currently known as currentPath. Will make working with relative paths ("zooming in") easier. => Alternatively, the callees are responsible for determining the absolute path.schemaPreprocesssor
to get the GUI optimized schemaResponsiblities:
The session store will be responsible for providing the correct data manager for the current page.
This class could be used as a prop in components to reduce dependecies to the session store (optional).
Todos
FormatRegistry
toDataLink
SchemaPreprocessor
DataManager
Beta Was this translation helpful? Give feedback.
All reactions