514136c99a
Problem: Prettier was not running when I saved Emacs buffers. Why? - prettier-js-mode needs needs node; lorri exposes node to direnv; direnv exposes node to Emacs; lorri was not working as expected. Solution: Now that I'm using nix-buffer, I can properly expose node (and other dependencies) to my Emacs buffers. Now Prettier is working. Commentary: Since prettier hadn't worked for so long, I stopped thinking about it. As such, I did not include it as a dependency in boilerplate/typescript. I added it now. I retroactively ran prettier across a few of my frontend projects to unify the code styling. I may need to run... ```shell $ cd ~/briefcase $ nix-shell $ npx prettier --list-different "**/*.{js,ts,jsx,tsx,html,css,json}" ``` ...to see which files I should have formatted.
36 lines
898 B
TypeScript
36 lines
898 B
TypeScript
import { createSlice, configureStore, PayloadAction } from "@reduxjs/toolkit";
|
|
import { useSelector, TypedUseSelectorHook } from "react-redux";
|
|
|
|
export interface Book {
|
|
title: string;
|
|
author: string;
|
|
// TODO(wpcarro): Prefer datetime type here.
|
|
publicationDate: string;
|
|
}
|
|
|
|
export interface State {
|
|
isLoading: boolean;
|
|
books: Book[];
|
|
}
|
|
|
|
const initialState: State = {
|
|
isLoading: true,
|
|
books: [],
|
|
};
|
|
|
|
export const { actions, reducer } = createSlice({
|
|
name: "application",
|
|
initialState,
|
|
reducers: {
|
|
toggleIsLoading: (state) => ({ ...state, isLoading: !state.isLoading }),
|
|
setBooks: (state, action) => ({ ...state, books: action.payload }),
|
|
},
|
|
});
|
|
|
|
/**
|
|
* Defining and consuming this allows us to avoid annotating State in all of our
|
|
* selectors.
|
|
*/
|
|
export const useTypedSelector: TypedUseSelectorHook<State> = useSelector;
|
|
|
|
export default configureStore({ reducer });
|