小编Mic*_*ely的帖子

.Angular 应该在 gitignore 中

我最近使用命令将 Angular 从 v12 升级到 v14 ng update,并手动进行了所需的修改。该命令添加了一个.angular带有缓存库的文件夹,该文件夹看起来很大:

在此输入图像描述

但它没有将缓存文件夹添加到.gitignore.

我应该添加.angular到我的吗.gitignore

angular angular14upgrade

15
推荐指数
1
解决办法
5470
查看次数

取消iOS麦克风回声消除和噪音抑制

有没有办法取消iOS录音机中的回声消除和噪声抑制等预处理?

我正在使用AVAudioRecorderwith ,并且使用(docsmeteringEnabled=true )获得平均分贝级别。averagePowerForChannel

我正在尝试测量手机附近的环境噪音,如果我开始说话,iPhone 8 似乎会放大低噪音或将其抵消。例如,如果背景音乐的绝对分贝级为 30 - iOS 似乎会放大它。当我开始小声说话时,分贝水平显着下降。

但由于我想测量环境噪声 - 我不需要这种预处理。

我尝试过setInputGain文档)但isInputGainSettable总是错误的 - 因此,我不能采用这种方法。

有没有办法取消任何放大或预处理,例如回声消除和噪声抑制?

avaudiorecorder ios avaudiosession

5
推荐指数
1
解决办法
3352
查看次数

take(1) vs firstValueFrom vs observable.value

在我的项目中,我使用BehaviorSubjects 作为数据存储来存储应用程序的状态。

我只需要存储中当前保存的当前BehaviorSubject值,不需要订阅可以通过行为主体发出的未来值。

我发现很少有实现此操作的方法:使用pipe(take(1)),firstValueFrom.value

所有的工作方式都相同并读取BehaviorSubject 存储中的当前值吗?如果有的话,它们之间有什么区别?

private myStore$: BehaviorSubject<boolean> = new BehaviorSubject<boolean>(false);

// reading only one current value using take(1):
this.myStore$.pipe(take(1))
    .subscribe(value => console.log('current value = ', value));

// reading only one current value using firstValueFrom:
const value = await firstValueFrom(this.myStore$);
console.log('current value = ', value);

// reading only one current value using this.myStore$.value:
const value = this.myStore$.value;
console.log('current value = ', value);
Run Code Online (Sandbox Code Playgroud)

rxjs angular2-observables angular

5
推荐指数
1
解决办法
2万
查看次数

如何实现使用 CanMatchFn 和 CanActivateFn 的 Angular AuthGuard?(如何将类守卫转换为功能守卫)

我有以下 Angular AuthGuard:

\n
@Injectable({\n    providedIn: \'root\',\n})\nexport class AuthGuard implements CanActivate, CanLoad {\n    constructor(private authService: AuthService, private router: Router) {}\n\n    canActivate(\n        next: ActivatedRouteSnapshot,\n        state: RouterStateSnapshot,\n    ): | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> | boolean | UrlTree {\n        return this.isAuthenticated();\n    }\n\n    canLoad(\n        route: Route,\n        segments: UrlSegment[],\n    ): | boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {\n        return this.isAuthenticated();\n    }\n\n    isAuthenticated(): | boolean | UrlTree | Observable<boolean | UrlTree> | Promise<boolean | UrlTree> {\n        return this.authService.isAuthenticated$.pipe(\n …
Run Code Online (Sandbox Code Playgroud)

angular angular14 angular15

5
推荐指数
1
解决办法
7049
查看次数