feat(utils): add utils library with a fake ramdon generator

This commit is contained in:
thomas
2022-12-15 17:04:07 +01:00
parent 0979a9f3db
commit c60791a530
13 changed files with 192 additions and 10 deletions

View File

@@ -20,7 +20,8 @@
"apps/rxjs-pipe-bug/src/assets"
],
"styles": ["apps/rxjs-pipe-bug/src/styles.scss"],
"scripts": []
"scripts": [],
"allowedCommonJsDependencies": ["seedrandom"]
},
"configurations": {
"production": {

View File

@@ -1,6 +1,6 @@
/* eslint-disable @typescript-eslint/member-ordering */
import { randomError } from '@angular-challenges/shared/utils';
import { Injectable } from '@angular/core';
import { randNumber } from '@ngneat/falso';
import { ComponentStore } from '@ngrx/component-store';
import { of } from 'rxjs';
@@ -47,12 +47,12 @@ export class LocalDBService extends ComponentStore<DBState> {
})
);
deleteOneTopic = (id: number) => {
const randomNumber = randNumber({ min: 0.1, max: 1, fraction: 2 });
if (randomNumber > 0.5) {
this.deleteOne(id);
return of(true);
}
return of(false);
};
deleteOneTopic = (id: number) =>
randomError({
success: () => {
this.deleteOne(id);
return of(true);
},
error: () => of(false),
});
}