UNPKG

@spartacus/user

Version:

User feature library for Spartacus

79 lines (70 loc) 3.89 kB
import * as i0 from '@angular/core'; import { InjectionToken, Injectable, NgModule } from '@angular/core'; import { UserAccountChangedEvent, UserAccountFacade } from '@spartacus/user/account/root'; import * as i2 from '@spartacus/core'; import { LoginEvent, LogoutEvent } from '@spartacus/core'; import { switchMap } from 'rxjs/operators'; const USER_ACCOUNT_NORMALIZER = new InjectionToken('UserAccountNormalizer'); const USER_ACCOUNT_SERIALIZER = new InjectionToken('UserAccountSerializer'); class UserAccountAdapter { } class UserAccountConnector { constructor(adapter) { this.adapter = adapter; } get(userId) { return this.adapter.load(userId); } } UserAccountConnector.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountConnector, deps: [{ token: UserAccountAdapter }], target: i0.ɵɵFactoryTarget.Injectable }); UserAccountConnector.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountConnector }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountConnector, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: UserAccountAdapter }]; } }); class UserAccountService { constructor(userAccountConnector, userIdService, query) { this.userAccountConnector = userAccountConnector; this.userIdService = userIdService; this.query = query; this.userQuery = this.query.create(() => this.userIdService .takeUserId(true) .pipe(switchMap((userId) => this.userAccountConnector.get(userId))), { reloadOn: [UserAccountChangedEvent], resetOn: [LoginEvent, LogoutEvent], }); } /** * Returns the current user. */ get() { return this.userQuery.get(); } } UserAccountService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountService, deps: [{ token: UserAccountConnector }, { token: i2.UserIdService }, { token: i2.QueryService }], target: i0.ɵɵFactoryTarget.Injectable }); UserAccountService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountService }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountService, decorators: [{ type: Injectable }], ctorParameters: function () { return [{ type: UserAccountConnector }, { type: i2.UserIdService }, { type: i2.QueryService }]; } }); const facadeProviders = [ UserAccountService, { provide: UserAccountFacade, useExisting: UserAccountService, }, ]; class UserAccountCoreModule { } UserAccountCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); UserAccountCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountCoreModule }); UserAccountCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountCoreModule, providers: [UserAccountConnector, ...facadeProviders] }); i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.0.5", ngImport: i0, type: UserAccountCoreModule, decorators: [{ type: NgModule, args: [{ providers: [UserAccountConnector, ...facadeProviders], }] }] }); /** * Generated bundle index. Do not edit. */ export { USER_ACCOUNT_NORMALIZER, USER_ACCOUNT_SERIALIZER, UserAccountAdapter, UserAccountConnector, UserAccountCoreModule, UserAccountService }; //# sourceMappingURL=spartacus-user-account-core.js.map