@genesislcap/foundation-user
TypeScript icon, indicating that this package has built-in type declarations

14.192.0 • Public • Published

Genesis User

lerna TypeScript

foundation-user provides the User singleton, which always exists in either an anonymous or authenticated mode.

Get User reference

User is a singleton. You can access it via the DI container.

import { User } from '@genesislcap/foundation-user';
...
@User private user: User

...or via a utility if your app is not using decorators or the DI container.

import { getUser } from '@genesislcap/foundation-user';
...
private user = getUser();

User properties are decorated with @observable, meaning in FAST terms it's reactive, and you can bind to properties directly. For example, this.user.isAuthenticated. However, you can also monitor the user's authentication status using an event listener.

import type { UserAuthenticationChangeEvent } from '@genesislcap/foundation-user';
...
const unsubscribeUser = this.user.addAuthenticationChangeListener((event: UserAuthenticationChangeEvent) => {
  console.log('User authenticated?', event.detail); // < boolean === this.user.isAuthenticated
});

See the User API Docs for more information.

Installation

To enable this module in your application, follow the steps below.

  1. Add @genesislcap/foundation-user as a dependency in your package.json file. Whenever you change the dependencies of your project, ensure you run the $ npm run bootstrap command again. You can find more information in the package.json basics page.
{
  ...
  "dependencies": {
    ...
    "@genesislcap/foundation-user": "latest"
    ...
  },
  ...
}

License

Note: this project provides front-end dependencies and uses licensed components listed in the next section; thus, licenses for those components are required during development. Contact Genesis Global for more details.

Licensed components

Genesis low-code platform

/@genesislcap/foundation-user/

    Package Sidebar

    Install

    npm i @genesislcap/foundation-user

    Weekly Downloads

    3,221

    Version

    14.192.0

    License

    SEE LICENSE IN license.txt

    Unpacked Size

    254 kB

    Total Files

    130

    Last publish

    Collaborators

    • genesisnpm