Lime Web Components API Documentation - v6.24.0
    Preparing search index...

    Function SelectCurrentUser

    • 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.

      Parameters

      Returns PropertyDecorator

      A PropertyDecorator that sets up automatic subscription to the current user

      Subscribes to: ApplicationRepository

      Updates: The decorated property with the User object

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

      @State()
      @SelectCurrentUser()
      private user: User;
      // Extract user's full name
      @State()
      @SelectCurrentUser({
      map: [(user) => user?.fullname]
      })
      private userName: string;
      // 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;