export const UserPreferences = defineStorage({
key: 'preferences',
scope: 'global',
version: 2,
defaultValue: { theme: 'dark' },
migrations: { 1: (old) => ({ ...(old as object), theme: 'dark' }) },
syncable: true,
});
module.storage.add(UserPreferences);
module.commands.handle(Refresh, {
inject: { preferences: UserPreferences.token },
execute: (context, _args, { preferences }) => preferences.get().theme,
});
Declares a typed, versioned storage.
The definition doubles as the service token for its accessor, so a handler injects storage the same way it injects anything else.