angular-architects / ngrx-toolkit

Various Extensions for the NgRx Signal Store
MIT License
104 stars 17 forks source link

DX-friendlier actions creators #2

Open rainerhahnekamp opened 6 months ago

rainerhahnekamp commented 6 months ago

We initialize already our state with properties like:

withState({flights: [] as Flight[]})

On the other hand, an action requires a payload function (or props in NgRx Global Store):

withRedux({actions: {search: payload<{from: string, to: string>()}})

What if we introduce a second approach with type inference like:

withRedux({actions: {search: {from: '', to; ''}}})

For more complicated cases, payload will still be an option.

rosostolato commented 6 months ago

A question that might not be related: why do we need the actions to be internal to the store? Why not have external actions created with the createAction function?

This way we can save the actions on a separate file and cleanup the store.

rainerhahnekamp commented 6 months ago

Yeah, that's planned in #3