TecKnow / muster-tools

A package for assigning players to tables at multi-table, walk-in gaming events.
GNU General Public License v3.0
0 stars 0 forks source link

What happens if there is an exception on signin? #16

Closed TecKnow closed 3 years ago

TecKnow commented 3 years ago

https://github.com/TecKnow/muster-tools/blob/b3f3d2531a598041a8c535128dd63f5e1fec30f5/muster_client/src/Signin.js#L45-L45

TecKnow commented 3 years ago

It was decided that individual React components should not call the API directly. Instead, they should use the useDispatch() hook of react-rdux and call asynchronous action creators (thunks). Thunks are created using the createAsyncThunk() function of @reduxjs-toolkit so exceptions are handled by dispatching <ActionType>.rejected actions. Special handling for erros on adding a new player, compared to any other error, is no longer required.

Errors can be handled in the component that dispatched the thunk using _@reduxjs-toolkit__ unwrapResult() or with reducers. Please see []Redux Essentials, Part 5: Async Logic and Data Fetching](https://redux.js.org/tutorials/essentials/part-5-async-logic) for an example of using unwrapResult().