Show HN: TopHat Finance – free, open, and offline
Looks very nice!<p>I see you&#x27;re using Redux Toolkit and TypeScript, including some fairly heavy use of `createEntityAdapter`.  Any feedback on using RTK?  We&#x27;re always interested in hearing how RTK is working for our users.<p>A couple quick suggestions on the code itself:<p>- I see a lot of custom hooks like `useAccountsPageState` [0], except that they&#x27;re completely duplicating the `useSelector` signature. I think the right answer here is to start by defining the &quot;pre-typed&quot; `useAppSelector` hook we show in our TS usage docs [1].  Then, make sure your selectors have the correct `RootState` type. Finally, you can rewrite the hook as `const useAccountsPageState = () =&gt; useAppSelector(selectPageState)`.<p>- It looks like you&#x27;re importing `TopHatDispatch` into some other files.  That has the risk of causing circular import problems, since it&#x27;s importing from the store itself.  You may want to rework functions like `updateSyncedCurrencies` [2] to be a thunk.  (In fact, looking at the code, this looks like a very good candidate for RTK&#x27;s `createAsyncThunk` API.)  Also, it looks like this is going to end up dispatching a separate action for every item.  It would probably be more efficient to fetch all the items first, then dispatch _one_ action with the combined fetched results.<p>[0] <a href="https:&#x2F;&#x2F;github.com&#x2F;Athenodoros&#x2F;TopHat&#x2F;blob&#x2F;a916386edf&#x2F;src&#x2F;state&#x2F;app&#x2F;hooks.ts" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Athenodoros&#x2F;TopHat&#x2F;blob&#x2F;a916386edf&#x2F;src&#x2F;st...</a><p>[1] <a href="https:&#x2F;&#x2F;redux.js.org&#x2F;tutorials&#x2F;typescript-quick-start#define-typed-hooks" rel="nofollow">https:&#x2F;&#x2F;redux.js.org&#x2F;tutorials&#x2F;typescript-quick-start#define...</a><p>[2] <a href="https:&#x2F;&#x2F;github.com&#x2F;Athenodoros&#x2F;TopHat&#x2F;blob&#x2F;a916386edf&#x2F;src&#x2F;state&#x2F;logic&#x2F;currencies.ts#L70" rel="nofollow">https:&#x2F;&#x2F;github.com&#x2F;Athenodoros&#x2F;TopHat&#x2F;blob&#x2F;a916386edf&#x2F;src&#x2F;st...</a>