type'可观察< void>'无法分配到type'可观察的boolean>'
知道该怎么办
我
不 它一直告诉我 类型“可观察”不能分配给“可观察到的”。 键入“ void”不可分配给“布尔值”。
但是,当我将其更改为无效时,它也不适用
于不良英语的不良英语,
这是代码的
import { Component, OnDestroy , OnInit } from '@angular/core';
import { AuthsService } from '../auths.service';
import { FormBuilder,FormGroup,Validators } from '@angular/forms';
import { UiService } from 'src/app/shared/ui.service';
import { Subscription,Observable, map } from 'rxjs';
import { select, Store } from '@ngrx/store';
import * as fromRoot from '../../app.reducer';
import * as fromLoading from '../../shared/load.reducer'
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
loginForm!: FormGroup;
constructor(private Authservice: AuthsService, private fb: FormBuilder, private uiService: UiService,
private Stoore: Store<{ui:fromLoading.State}>
) { }
private loadingSub: Subscription;
isloading$: Observable<boolean>;
ngOnInit(): void {
this.isloading$ = this.Stoore.pipe(map(state => { state.ui.theLoading }));
this.loginForm = this.fb.group({
email: ['', Validators.required],
password:['',Validators.required]
})
}
onSubmit() {
this.Authservice.login({
email:this.loginForm.value.email,
password:this.loginForm.value.password
})
}
}
REDUCER代码,
export interface State {
theLoading: boolean;
}
const initialState: State = {
theLoading:false
}
export function LoadingReducer(state = initialState, action) {
switch (action.type) {
case 'START_LOADING':
return {
theLoading: true,
}
case 'STOP_LOADING':
return {
theLoading:false
}
default :
return {
state
}
}
}
我想将其存储在
this.isloading $ = this.stoore.pipe(Map(state =&gt; {state state)。 ui.theloading}));
但是它一直告诉我
TS2322: Type 'Observable<void>' is not assignable to type 'Observable<boolean>'.
Type 'void' is not assignable to type 'boolean'.
I do not know what should i do can anyone help me please
I made the reducer and added the cases
but my problem is when I connect the reducer with the observable
it keep telling me
Type 'Observable' is not assignable to type 'Observable'.
Type 'void' is not assignable to type 'boolean'.
but when i changed it to void it dose not also work
sorry for the bad english
here is the code
import { Component, OnDestroy , OnInit } from '@angular/core';
import { AuthsService } from '../auths.service';
import { FormBuilder,FormGroup,Validators } from '@angular/forms';
import { UiService } from 'src/app/shared/ui.service';
import { Subscription,Observable, map } from 'rxjs';
import { select, Store } from '@ngrx/store';
import * as fromRoot from '../../app.reducer';
import * as fromLoading from '../../shared/load.reducer'
@Component({
selector: 'app-login',
templateUrl: './login.component.html',
styleUrls: ['./login.component.scss']
})
export class LoginComponent implements OnInit {
loginForm!: FormGroup;
constructor(private Authservice: AuthsService, private fb: FormBuilder, private uiService: UiService,
private Stoore: Store<{ui:fromLoading.State}>
) { }
private loadingSub: Subscription;
isloading$: Observable<boolean>;
ngOnInit(): void {
this.isloading$ = this.Stoore.pipe(map(state => { state.ui.theLoading }));
this.loginForm = this.fb.group({
email: ['', Validators.required],
password:['',Validators.required]
})
}
onSubmit() {
this.Authservice.login({
email:this.loginForm.value.email,
password:this.loginForm.value.password
})
}
}
the reducer code
export interface State {
theLoading: boolean;
}
const initialState: State = {
theLoading:false
}
export function LoadingReducer(state = initialState, action) {
switch (action.type) {
case 'START_LOADING':
return {
theLoading: true,
}
case 'STOP_LOADING':
return {
theLoading:false
}
default :
return {
state
}
}
}
I want to store it in
this.isloading$ = this.Stoore.pipe(map(state => { state.ui.theLoading }));
but it keep telling me
TS2322: Type 'Observable<void>' is not assignable to type 'Observable<boolean>'.
Type 'void' is not assignable to type 'boolean'.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论