-
-
Notifications
You must be signed in to change notification settings - Fork 323
Open
Description
Hey there, thanks for amazing library!
Currently, keys for values in a storage aren't typed, they are just strings.
Having ability to pass an optional generic type when initializing a new mmkv instance could improve developer experience.
This will allow to specify which values are usable with particular storage instance. Example:
type StorableValues = 'token' | 'userId';
export const storage = new MMKV<StorableValues>({ ... });
...
storage.getString('foo'); // Typescript will report this error
storage.getString('token'); // All goodOf course, this can be achieved using a separate enum for keys in the app, but having generic support is more elegant and easier in use.
Please let me know if this feature is desirable, and you'd like me to submit a PR with these changes!
xtyrrell, RuslanAktaev, Tomass673, mikhail-create, Al1erEgo and 6 more
Metadata
Metadata
Assignees
Labels
No labels