-
Notifications
You must be signed in to change notification settings - Fork 39
refactor: Refactor model initialization logic #923
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR refactors model initialization logic to be fully generic instead of being hardcoded for layer initialization, preparing for future support of additional reactive widget models like views and basemap styles.
- Moved generic model loading logic from
util.ts
to a new dedicatedmodel/initialize.ts
file - Created a generic
initializeChildModels
function that can handle any type of child model with proper lifecycle management - Updated layer initialization to use the new generic infrastructure while maintaining existing functionality
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
File | Description |
---|---|
src/util.ts | Removed layer-specific loadChildModels function to consolidate model loading logic |
src/model/initialize.ts | Added new generic model initialization utilities with proper lifecycle management |
src/model/index.ts | Exported the new initializeChildModels function for external use |
src/model/base-layer.ts | Updated to use generic model initialization and changed extensions from array to Record |
src/index.tsx | Refactored to use the new generic model initialization infrastructure |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Open to comments still, but this is a pretty straightforward refactor I think, so I'll merge so that I can use it in #935 |
In ipywidgets, a "model" is the core of reactivity. In particular, a Lonboard
Map
is reactive, but every underlying layer is also reactive, so that when a user changes any property on a layer, it automatically gets updated on the map.By extension, our
Extension
classes are also themselves models. These are separate Python classes that get serialized as their own reactive models on the JS side.Soon we'll have more types of widget models that we want to be reactive, including views and basemap styles (#908).
Right now, model initialization is slightly hard-coded to handle layer initialization. This PR refactors the model initialization to be fully generic.