-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
[ML] Move local storage utilities to package. #148049
Conversation
e968adf
to
19faca0
Compare
8093d7e
to
a5080a8
Compare
9989ef9
to
eea9870
Compare
Pinging @elastic/ml-ui (:ml) |
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.
Would be good to add comments to the public APIs before merging this, but otherwise code LGTM.
@@ -5,4 +5,4 @@ | |||
* 2.0. | |||
*/ | |||
|
|||
export { MlStorageContextProvider, useStorage } from './storage_context'; | |||
export { isDefined } from './src/is_defined'; |
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.
Could you add a comment to this exported function to keep the 'public APIs without comments' count at 0?
storageKeys: readonly K[]; | ||
} | ||
|
||
export function StorageContextProvider<K extends TStorageKey, T extends TStorage>({ |
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.
Could you add a comment to this to keep the 'public APIs without comments' count at 0 for this package.
removeValue: <K extends TStorageKey>(key: K) => void; | ||
} | ||
|
||
export function isStorageKey<T>(key: unknown, storageKeys: readonly T[]): key is T { |
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.
Could you add a comment to this to keep the 'public APIs without comments' count at 0 for this package.
return storageKeys.includes(key as T); | ||
} | ||
|
||
export const MlStorageContext = React.createContext<StorageAPI>({ |
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.
Could you add a comment to this to keep the 'public APIs without comments' count at 0 for this package.
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.
Gave this a test and looks to be working as expected. LGTM ⚡
💚 Build Succeeded
Metrics [docs]Module Count
Public APIs missing comments
Async chunks
Page load bundle
Unknown metric groupsAPI count
History
To update your PR or re-run it, just comment with: cc @walterra |
Summary
Part of #136182.
Follow up to #147912.
Moves multiple copies of
useStorage()
and related code to a package as a single source. The different copies with hard coded types have been adapted souseStorage()
is now based on generics. Also moves duplicates ofisDefined()
to its own package.Some duplicate settings related to
FROZEN_TIER_PREFERENCE
remain, this will be deduplicated in the follow up in #148063.