-
Notifications
You must be signed in to change notification settings - Fork 8.2k
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
D/2021 09 13 async registry #111954
D/2021 09 13 async registry #111954
Conversation
237af74
to
2660eff
Compare
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Any counts in public APIs
Async chunks
Public APIs missing exports
Page load bundle
Unknown metric groupsAPI count
async chunk count
References to deprecated APIs
History
To update your PR or re-run it, just comment with: |
id: FIELD_FORMAT_IDS.DATE, | ||
load: () => import('./converters').then((m) => m.DateFormat), | ||
}, | ||
{ |
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.
On the client-side we register "loader" instead of full items
@@ -52,7 +52,9 @@ export class FieldFormatsRegistry { | |||
init( | |||
getConfig: FieldFormatsGetConfigFn, | |||
metaParamsOptions: FieldFormatMetaParams = {}, | |||
defaultFieldConverters: FieldFormatInstanceType[] = baseFormatters | |||
defaultFieldConverters: |
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.
Common class has to work with both: full-field formatter registry items (for the server-side) and loaders (for the client-side)
|
||
export class FieldFormatsRegistry { | ||
protected fieldFormats: Map<FieldFormatId, FieldFormatInstanceType> = new Map(); | ||
protected readonly fieldFormats = new KbnRegistry<FieldFormatInstanceType>(); |
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.
Changing internal Map
to KbnRegistry
to store registry items and support async loading
@@ -16,7 +16,8 @@ import { | |||
} from '../../../core/server'; | |||
import { FieldFormatsStart, FieldFormatsSetup } from './types'; | |||
import { DateFormat, DateNanosFormat } from './lib/converters'; | |||
import { baseFormatters, FieldFormatInstanceType, FieldFormatsRegistry } from '../common'; | |||
import { FieldFormatInstanceType, FieldFormatsRegistry } from '../common'; | |||
import { baseFormatters } from '../common/constants/base_formatters'; |
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.
Server still registers everything eagerly, but client registers only loaders
isLoaded(id: string): boolean; | ||
} | ||
|
||
export class KbnRegistry< |
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.
Draft registry implementation
Summary
POC for #65993
Making field formatter registry async