我的一位同事问我是否需要取消订阅对话框的 afterClosed() Observable。
我们使用 takeUntil 模式取消订阅 ngOnDestroy() 上的所有 Observable。
this.backEvent = fromEvent(window, 'popstate')
.pipe(
takeUntil(this.destroy$)
)
.subscribe(
() => {
this.navigationService.backClicked = true;
this.navigationService.navigateBackToDirectoryCenter();
}
);
Run Code Online (Sandbox Code Playgroud)
ngOnDestroy()
ngOnDestroy() {
this.destroy$.next();
this.destroy$.complete();
}
Run Code Online (Sandbox Code Playgroud)
那么是否有必要取消订阅 afterClosed() Observable 呢?
dialogRef.afterClosed().subscribe(
(data) => {
console.log(data);
}
},
);
Run Code Online (Sandbox Code Playgroud)
或者?
dialogRef.afterClosed()
.pipe(
takeUntil(this.destroy$)
)
.subscribe(
(data) => {
console.log(data);
},
);
Run Code Online (Sandbox Code Playgroud) 我需要你的帮助!我有两个模型customer和membership。客户hasMany会员资格。我需要提取具有成员资格的所有客户active。我这样做了,但是它只提取成员身份,而没有客户数据。如何更改它以解决问题?
Membership::has("customer")
->forCompany($companyId)
->whereIn('state', ['ATTIVA', 'IN ATTESA DI ESITO', 'DA INVIARE'])
->where(function ($query) {
$query
->where('end_date', '>=', Carbon::now()->toDateString())
->orWhereNull('end_date');
})
Run Code Online (Sandbox Code Playgroud)