Skip to content

Commit

Permalink
Revert "Update all READMEs"
Browse files Browse the repository at this point in the history
This reverts commit 27fe907.
  • Loading branch information
aryaemami59 committed Jan 26, 2024
1 parent 6ffb9e9 commit 5fc7871
Show file tree
Hide file tree
Showing 3 changed files with 109 additions and 736 deletions.
212 changes: 35 additions & 177 deletions packages/rtk-codemods/transforms/createReducerBuilder/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,159 +31,38 @@ node ./bin/cli.js createReducerBuilder path/of/files/ or/some**/*glob.js

## <!--FIXTURES_CONTENT_START-->

---

<a id="basic-ts">**basic-ts**</a>

**Input** (<small>[basic-ts.input.ts](transforms\createReducerBuilder__testfixtures__\basic-ts.input.ts)</small>):

```ts
import type { PayloadAction } from '@reduxjs/toolkit'
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'

export interface Todo {
id: string
title: string
}

export const todoAdapter = createEntityAdapter<Todo>()

const todoInitialState = todoAdapter.getInitialState()

export type TodoSliceState = typeof todoInitialState

const { addOne } = todoAdapter

createReducer(todoInitialState, {
[todoAdded1a]: (state: TodoSliceState, action: PayloadAction<string>) => {
createReducer(initialState, {
[todoAdded]: (state: SliceState, action: PayloadAction<string>) => {
// stuff
},
[todoAdded1b]: (state: TodoSliceState, action: PayloadAction<string>) =>
action.payload,
[todoAdded1c + 'test']: (
state: TodoSliceState,
action: PayloadAction<string>
) => {
// stuff
},
[todoAdded1d](state: TodoSliceState, action: PayloadAction<string>) {
// stuff
},
[todoAdded1e]: function (
state: TodoSliceState,
action: PayloadAction<string>
) {
// stuff
},
todoAdded1f: (state: TodoSliceState, action: PayloadAction<string>) => {
//stuff
},
[todoAdded1g]: addOne,
todoAdded1h: todoAdapter.addOne
})
});

createReducer(todoInitialState, {
[todoAdded2a]: (state: TodoSliceState, action: PayloadAction<string>) => {
createReducer(initialState, {
[todoAdded](state: SliceState, action: PayloadAction<string>) {
// stuff
},
[todoAdded2b](state: TodoSliceState, action: PayloadAction<string>) {
// stuff
},
[todoAdded2c]: function (
state: TodoSliceState,
action: PayloadAction<string>
) {
// stuff
}
})
});
```

**Output** (<small>[basic-ts.output.ts](transforms\createReducerBuilder__testfixtures__\basic-ts.output.ts)</small>):

```ts
import type { PayloadAction } from '@reduxjs/toolkit'
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'

export interface Todo {
id: string
title: string
}

export const todoAdapter = createEntityAdapter<Todo>()

const todoInitialState = todoAdapter.getInitialState()

export type TodoSliceState = typeof todoInitialState

const { addOne } = todoAdapter

createReducer(todoInitialState, (builder) => {
builder.addCase(
todoAdded1a,
(state: TodoSliceState, action: PayloadAction<string>) => {
// stuff
}
)

builder.addCase(
todoAdded1b,
(state: TodoSliceState, action: PayloadAction<string>) => action.payload
)

builder.addCase(
todoAdded1c + 'test',
(state: TodoSliceState, action: PayloadAction<string>) => {
// stuff
}
)

builder.addCase(
todoAdded1d,
(state: TodoSliceState, action: PayloadAction<string>) => {
// stuff
}
)

builder.addCase(
todoAdded1e,
(state: TodoSliceState, action: PayloadAction<string>) => {
// stuff
}
)

builder.addCase(
todoAdded1f,
(state: TodoSliceState, action: PayloadAction<string>) => {
//stuff
}
)

builder.addCase(todoAdded1g, addOne)
builder.addCase(todoAdded1h, todoAdapter.addOne)
})

createReducer(todoInitialState, (builder) => {
builder.addCase(
todoAdded2a,
(state: TodoSliceState, action: PayloadAction<string>) => {
// stuff
}
)

builder.addCase(
todoAdded2b,
(state: TodoSliceState, action: PayloadAction<string>) => {
// stuff
}
)

builder.addCase(
todoAdded2c,
(state: TodoSliceState, action: PayloadAction<string>) => {
// stuff
}
)
})
createReducer(initialState, (builder) => {
builder.addCase(todoAdded, (state: SliceState, action: PayloadAction<string>) => {
// stuff
});
});

createReducer(initialState, (builder) => {
builder.addCase(todoAdded, (state: SliceState, action: PayloadAction<string>) => {
// stuff
});
});
```

---
Expand All @@ -193,15 +72,7 @@ createReducer(todoInitialState, (builder) => {
**Input** (<small>[basic.input.js](transforms\createReducerBuilder__testfixtures__\basic.input.js)</small>):

```js
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'

export const todoAdapter = createEntityAdapter()

const todoInitialState = todoAdapter.getInitialState()

const { addOne } = todoAdapter

createReducer(todoInitialState, {
createReducer(initialState, {
[todoAdded1a]: (state, action) => {
// stuff
},
Expand All @@ -218,11 +89,9 @@ createReducer(todoInitialState, {
todoAdded1f: (state, action) => {
//stuff
},
[todoAdded1g]: addOne,
todoAdded1h: todoAdapter.addOne
})
});

createReducer(todoInitialState, {
createReducer(initialState, {
[todoAdded2a]: (state, action) => {
// stuff
},
Expand All @@ -231,61 +100,50 @@ createReducer(todoInitialState, {
},
[todoAdded2c]: function (state, action) {
// stuff
}
})
},
});
```

**Output** (<small>[basic.output.js](transforms\createReducerBuilder__testfixtures__\basic.output.js)</small>):

```js
import { createEntityAdapter, createReducer } from '@reduxjs/toolkit'

export const todoAdapter = createEntityAdapter()

const todoInitialState = todoAdapter.getInitialState()

const { addOne } = todoAdapter

createReducer(todoInitialState, (builder) => {
createReducer(initialState, (builder) => {
builder.addCase(todoAdded1a, (state, action) => {
// stuff
})
});

builder.addCase(todoAdded1b, (state, action) => action.payload)
builder.addCase(todoAdded1b, (state, action) => action.payload);

builder.addCase(todoAdded1c + 'test', (state, action) => {
// stuff
})
});

builder.addCase(todoAdded1d, (state, action) => {
// stuff
})
});

builder.addCase(todoAdded1e, (state, action) => {
// stuff
})
});

builder.addCase(todoAdded1f, (state, action) => {
//stuff
})

builder.addCase(todoAdded1g, addOne)
builder.addCase(todoAdded1h, todoAdapter.addOne)
})
});
});

createReducer(todoInitialState, (builder) => {
createReducer(initialState, (builder) => {
builder.addCase(todoAdded2a, (state, action) => {
// stuff
})
});

builder.addCase(todoAdded2b, (state, action) => {
// stuff
})
});

builder.addCase(todoAdded2c, (state, action) => {
// stuff
})
})
});
});
```

<!--FIXTURES_CONTENT_END-->
Loading

0 comments on commit 5fc7871

Please sign in to comment.