[]
        
(Showing Draft Content)

GC.Spread.Common.UserManager

Class: UserManager

Spread.Common.UserManager

Table of contents

Constructors

Methods

Constructors

constructor

new UserManager()

Represent a user manager.

Methods

bind

Static bind(event, handler): void

Bind an event handler.

static

example

const users = spread.users;
users.bind(GC.Spread.Common.Events.CurrentUserChanged, (event, args) => {
    console.log(event);
    console.log(args.oldCurrentUser);
    console.log(args.newCurrentUser);
});

Parameters

Name Type Description
event Events Event type.
handler Function Event handler.

Returns

void


configure

Static configure(options): void

Configure the user manager options.

static

Parameters

Name Type Description
options IUserManagerOptions The user manager options.

Returns

void


current

Static current(userId?): undefined | string

Get or set the current user.

static

example

// navigate from the login page, and get the login user id
spread.users.current('715CFB19-2BB9-4B94-BE0C-08D0F9A019D4'); // { id: "715CFB19-2BB9-4B94-BE0C-08D0F9A019D4", name: "John Doe" }
console.log(spread.users.getSync(spread.users.current()).name); // "John Doe"

Parameters

Name Type
userId? string

Returns

undefined | string

The current user id.


get

Static get(userId): Promise<undefined | IUser>

Get a user by user id.

static

Parameters

Name Type Description
userId string The user id.

Returns

Promise<undefined | IUser>

The user.


unbind

Static unbind(event, handler): void

Unbind an event handler.

static

Parameters

Name Type Description
event Events Event type.
handler Function Event handler.

Returns

void