Home > database >  Cannot convert type value of type Observable<Store> to expected argument type Observable<St
Cannot convert type value of type Observable<Store> to expected argument type Observable<St

Time:10-30

I'm getting an error which says the following: Cannot convert value of type 'Observable<Store>' to expected argument type 'Observable<Store?>

So the method I'm calling StoreMock(state: stateSubject, store: storeSubject) seems to expect an optional for the observable storeSubject. But I'm not sure why it should matter if I pass in a non-optional. Shouldn't it be fine as it will always be there.

Any ideas?

CodePudding user response:

You have to wrap the object into an Optional: StoreMock(state: stateSubject, store: storeSubject.map(Optional.some))

Just one call will fix this.

  • Related