Configuration including key filtering and state transformation via SelectUserDataOptions
A PropertyDecorator that sets up automatic subscription to user data
Subscribes to: UserDataRepository
Updates: The decorated property with user data (object or specific value)
Lifecycle: Automatically subscribes in connectedCallback and
componentWillLoad, and unsubscribes in disconnectedCallback
import { State } from '@stencil/core';
import { SelectUserData } from '@limetech/lime-web-components';
class MyUserDataComponent {
@State()
@SelectUserData()
private userData: Record<string, unknown>;
}
import { State } from '@stencil/core';
import { SelectUserData } from '@limetech/lime-web-components';
class MyThemedComponent {
// The key narrows the state to that one entry, so the value handed to map
// is the theme itself and not the whole user data object
@State()
@SelectUserData({
key: 'theme',
map: [(theme) => theme || 'light'],
})
private selectedTheme: string;
}
Decorator that subscribes to user data from the UserDataRepository.
This decorator automatically updates the decorated property whenever user data changes in the platform. User data is persistent key-value storage associated with the current user. You can optionally filter by a specific key. It's the recommended approach over manual subscriptions as it handles subscription lifecycle automatically.