Conversation
…able hook at Home
create entities loading flow - useEntitiesLoader now works in different way, add refresh button, minor changes,
| "@typescript-eslint/interface-name-prefix": "off", | ||
| "@typescript-eslint/no-inferrable-types": "off", | ||
| "@typescript-eslint/no-explicit-any": "off", | ||
| "@typescript-eslint/no-empty-interface": "off", |
There was a problem hiding this comment.
Зачем ты отключил это не совсем понятно
| import { AnyAction } from 'redux'; | ||
|
|
||
| export enum Actions { | ||
| AddList = '[Entities] Add List', |
There was a problem hiding this comment.
Странноватый нейминг, скорее все таки принят UPPER_SNAKE_CASE
| @@ -0,0 +1,14 @@ | |||
| import { AnyAction } from 'redux'; | |||
There was a problem hiding this comment.
Тайпинг для пейлоада бы тоже прописать
| const { entities, key } = action.payload; | ||
| return { | ||
| ...state, | ||
| [key]: (state[key] || []).concat(entities), |
There was a problem hiding this comment.
Я бы написал [...(state[key] || []), ...entities]
| isInterrupted?: boolean; | ||
| } | ||
|
|
||
| export const affectState = <T, E = any>( |
There was a problem hiding this comment.
Абсолютно не понимаю, почему в ts принято буквами называть типы в дженериках, я стараюсь давать им нормальные названия. Ну кроме может быть T, но если их больше одного, то всегда называю как-то нормально.
| }; | ||
|
|
||
| const refreshFn = (): void => { | ||
| paginator.next(false); |
There was a problem hiding this comment.
Странноватое апи немного с флагом, не особо читается, что происходит. Было бы удобней какое-то явное апи типо loadNextPage, clearPages. Может быть его возвращать из хука. У меня в либе оно в класс обернуто.
| toIndex: number, | ||
| ): Observable<IBook[]> => from(fetchBooks(value, fromIndex, toIndex)); | ||
|
|
||
| const debouncedFilter$ = filter$.pipe( |
There was a problem hiding this comment.
Каждый раз создавать такой - не очень
| <div {...{ className: styles.wrapper }}> | ||
| {items.map((item) => { | ||
| <div {...{ className: classNames(styles.wrapper, className) }}> | ||
| {items?.map((item) => { |
There was a problem hiding this comment.
Заглушку бы какую-нибудь добавить, если нет items
| export const store = createStore( | ||
| rootReducer, | ||
| {}, | ||
| (window as any).__REDUX_DEVTOOLS_EXTENSION__ && (window as any).__REDUX_DEVTOOLS_EXTENSION__(), |
| return { type: Actions.AddList, payload: { entities, key } }; | ||
| }; | ||
|
|
||
| export const ReplaceList = <T>(entities: T[], key: string): AnyAction => { |
There was a problem hiding this comment.
Не хватает всякой работы с объектами по id, нормализации и прочих плюшек
There was a problem hiding this comment.
потому что все это в либе, не хочу еще раз этот путь проходить заного
add redux,
move books to redux state instead of useState of Home