spierala / mini-rx-store

MiniRx - The reactive state management platform
https://mini-rx.io
Other
170 stars 9 forks source link

An argument for 'observableOrValue' was not provided. #154

Closed marcpearson closed 5 months ago

marcpearson commented 1 year ago

When using effect that don't require an argument ( like loadTodos() is your documentation). Typescript complain about missing argument (observableOrValue: unknown) => void

feature-store.d.ts in line 15 =====> (observableOrValue: ObservableType | Observable) => void> the argument is not optional

Angular 15 "mini-rx-store": "^4.1.0", "mini-rx-store-ng": "^3.0.0", "typescript": "4.8.4",

spierala commented 1 year ago

Hi @marcpearson,

You can explicitly pass void as generic type in such cases. As you can see in this demo here: https://github.com/spierala/mini-rx-store/blob/master/apps/mini-rx-angular-demo/src/app/modules/todos/state/todos-store.service.ts#L107

Did you maybe update from mini-rx-store 3.x ? There was a breaking change for FeatureStore.effect in 4.0:

image

See the CHANGELOG here: https://github.com/spierala/mini-rx-store/blob/master/libs/mini-rx-store/CHANGELOG.md

I will further investigate in the coming days. Ideally the generic type should not be necessary if there is no argument for the effect.

marcpearson commented 1 year ago

Thanks for your help. I greatly appreciate it. After passing void my code compile again. But like you said we should not need to pass a generic if no argument for the effect

spierala commented 5 months ago

I will close this issue.

RxJS Subject has the same behavior... it requires an explicit void as generic type.

image

With explicit void:

image

Since this behavior is known from RxJS Subject, I do not see it as a real issue in MiniRx effect.