• Decorator that subscribes to the currently logged in user from the ApplicationRepository.

    This decorator automatically updates the decorated property whenever the current user changes in the platform. It's the recommended approach over manual subscriptions as it handles subscription lifecycle automatically.

    Returns

    A PropertyDecorator that sets up automatic subscription to the current user

    Remarks

    Subscribes to: ApplicationRepository

    Updates: The decorated property with the User object

    Lifecycle: Automatically subscribes in connectedCallback and unsubscribes in disconnectedCallback of the component.

    Example

    @State()
    @SelectCurrentUser()
    private user: User;

    Example

    // Extract user's full name
    @State()
    @SelectCurrentUser({
    map: [(user) => user?.fullname]
    })
    private userName: string;

    Example

    // Create initials with map transformations
    @State()
    @SelectCurrentUser({
    map: [
    (user) => user?.fullname,
    (name) => name?.split(' ').map(n => n[0]).join('').toUpperCase()
    ],
    filter: [(initials) => initials !== undefined]
    })
    private userInitials: string;

    Parameters

    Returns PropertyDecorator