User
The User module is the primary module responsible for connecting the user to the ZDK system.
It requires a userToken to establish a connection and provides various actions and data accessors to
manage and retrieve user-related information.
- core
Initialization
The main module responsible for connecting the user by passing the appropriate userToken.
const user = new createUser({
config: {
host: 'user.dev.zu.casa'
}
});Host is a string representing the URL used to establish a connection to a specified environment within the ZDK system. This URL is critical for configuring the network settings that determine how the user’s client interacts with the API consumer services, including the retrieval of environment-specific data and features.
Actions
open
Action type(token: string) => Promise<User>
Initiates a user connection using a token as identification within the ZDK system. The token is a critical credential that packages user-specific data, as allocated by API consumer, which may encompass elements like nickname, full name, and avatar.
Parameterstoken- A unique string that validates and represents a user in the ZDK framework.
A promise that, upon resolution, yields the authenticated user’s information.
Possible errorsRpcError- This error is thrown if the provided token is deemed invalid.
close
Action type() => void
Executes the disconnection of the user from the ZDK system. This action should be invoked to cleanly terminate the user’s session and ensure that all associated resources are properly released.
Data (Getters)
status
Getter output type:
'inactive' | 'loading' | 'active'
Retrieves the current status of the user, reflecting their activity state within the ZDK system. Possible statuses include ‘inactive’ (no current activity or session), ‘loading’ (user-related processes are initializing), and ‘active’ (user is fully active and engaged within the system).
clientId
Getter output type:
string | undefined
Obtains the unique identifier assigned to the user’s client. This ID is used to manage and track the user’s session and interactions within the ZDK system. If the user’s client ID has not been set or is otherwise inaccessible, the getter will yield undefined.
clientNickname
Getter output type:
string | undefined
Provides the nickname associated with the user’s client, allowing for a more personalized user experience within the ZDK system. In cases where the nickname is not set or cannot be retrieved, the getter will return undefined.