-
-
Notifications
You must be signed in to change notification settings - Fork 3.5k
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
feat(typings): Enhance typing support with withAppTypes and custom services throughout OHIF #4090
Conversation
✅ Deploy Preview for ohif-platform-docs ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
✅ Deploy Preview for ohif-dev ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
platform/core/src/services/UserAuthenticationService/UserAuthenticationService.ts
Show resolved
Hide resolved
Passing run #3898 ↗︎
Details:
Review all test suite changes for PR #4090 ↗︎ |
extensions/cornerstone/src/components/CinePlayer/CinePlayer.tsx
Outdated
Show resolved
Hide resolved
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.
extensions/cornerstone/src/components/WindowLevelActionMenu/WindowLevelActionMenu.tsx
Show resolved
Hide resolved
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.
see my comment please
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.
Thank you for resolving this matter conclusively. Excellent work.
…rvices throughout OHIF (#4090)
Context
The goal of this PR is to enhance typing support throughout OHIF.
Extending App Types and Services in Your Application
This documentation provides an overview and examples on how to use and extend
withAppTypes
, integrate custom properties, and add services in the global namespace of the application. This helps in enhancing the application's modularity and extensibility.Overview of
withAppTypes
The
withAppTypes
function is a TypeScript utility that extends the base properties of components or modules with the application's core service and manager types. It allows for a more flexible and type-safe way to pass around core functionality and custom properties.Using
withAppTypes
withAppTypes
can be enhanced using generics to include custom properties. This is particularly useful for passing additional data or configurations specific to your component or service.Extending with Custom Properties
You can extend
withAppTypes
to include custom properties by defining an interface for the props you need. For example:In this example,
ColorbarProps
is a custom interface that extends the application types throughwithAppTypes
.Typing the custom extensions's new services
Extensions can define additional services that integrate seamlessly into the application's global service architecture, and will be available on the ServicesManager for use across the application.
Adding the extension's services Types
Declare your service in the global namespace and use it across your application as demonstrated below:
extensions/my-extension/src/types/whatever.ts
Doing the above adds the
microscopyService
to the global Services interface, which ServicesManager uses by defaultpublic services: AppTypes.Services = {};
to type services, and is also used by withAppTypes to inject services into components.You will also get access to the seperate services via
AppTypes.YourServiceName
in your application.