Start services#63720
Conversation
|
Pinging @elastic/kibana-app-arch (Team:AppArch) |
💚 Build SucceededTo update your PR or re-run it, just comment with: |
lukeelmers
left a comment
There was a problem hiding this comment.
This LGTM! I tested it in the data plugin (temporarily removing the service getters we were using in getInternalStartServices), and it all worked as expected.
You just have to remember to pass the correct parameters to the CoreSetup generic so that TS doesn't complain:
public setup(
core: CoreSetup<DataStartDependencies, DataPublicPluginStart>,
{ expressions, uiActions }: DataSetupDependencies
): DataPublicPluginSetup {
const startServices = createStartServicesGetter(core.getStartServices);
// ultimately we can just get rid of this function & instead pass `startServices`
const getInternalStartServices: GetInternalStartServicesFn = () => {
const { core: coreStart, self } = startServices();
return {
fieldFormats: self.fieldFormats,
notifications: coreStart.notifications,
};
};
// ...etc
}One pattern we could discuss as a next step is how we want to pass down a single service, in cases where we want to be explicit about which start services are actually required by a component. But IMO this solves the overarching problem in the simplest way possible.
One way is to use casting, this way code stays nice and clean. interface SomethingParams {
start: StartServicesGetter<Pick<MyPluginStartDeps, 'data'>>;
}
class Something {
constructor({ start }: SomethingParams) {
start().plugins.data.indexPatterns(...)
}
}and in plugin itself no changes needed: setup(core) {
const start = createStartServicesGetter(core.getStartServices);
new Something({ start });
} |
* master: (40 commits) [APM]Upgrade apm-rum agent to latest version to fix full page reload (elastic#63723) add deprecation warning for legacy 3rd party plugins (elastic#62401) Migrate timelion vis (elastic#62819) Replacebad scope link with actual values (elastic#63444) Index pattern management UI -> TypeScript and New Platform Ready (create_index_pattern_wizard) (elastic#63111) [SIEM] Threat hunting enhancements: Filter for/out value, Show top field, Copy to Clipboard, Draggable chart legends (elastic#61207) [Maps] fix term join agg key collision (elastic#63324) [Ingest] Fix agent config key sorting (elastic#63488) [Monitoring] Fixed server response errors (elastic#63181) update elastic charts to 18.3.0 (elastic#63732) Start services (elastic#63720) [APM] Encode spaces when creating ML job (elastic#63683) Uptime 7.7 docs (elastic#62228) [DOCS] Updates remote cluster and ccr docs (elastic#63517) [Maps] Add 3rd party vector tile support (elastic#62084) [Endpoint][EPM] Retrieve Index Pattern from Ingest Manager (elastic#63016) [Endpoint] Host Details Policy Response Panel (elastic#63518) [Uptime] Certificate expiration threshold settings (elastic#63682) Refactor saved object types to use `namespaceType` (elastic#63217) [SIEM][CASE] Create comments sequentially (elastic#63692) ...
Summary
Adds
createStartServicesGetterutility.Usage example:
Checklist
Delete any items that are not applicable to this PR.
For maintainers