Skip to content

Commit

Permalink
feat(slice): remove ngrx immer dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
Chau Tran committed Sep 27, 2022
1 parent 3405b98 commit 01c6687
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 21 deletions.
16 changes: 3 additions & 13 deletions packages/ngrx-slice/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,14 @@ yarn add ngrx-slice

### Peer Dependencies

`ngrx-slice` has `ngrx-immer` and `immer` as its `peerDependencies` so go ahead and install those:
`ngrx-slice` has `immer` as its `peerDependencies` so go ahead and install it:

```shell
npm install ngrx-immer immer
npm install immer
```

```shell
yarn add ngrx-immer immer
```

Here's one command for all three:

```shell
npm install ngrx-slice ngrx-immer immer
```

```shell
yarn add ngrx-slice ngrx-immer immer
yarn add immer
```

## Documentations
Expand Down
5 changes: 1 addition & 4 deletions packages/ngrx-slice/src/lib/create-slice-reducer.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ const initialState = {
foo: 1,
};

const getter = (featureName: string, actionName: string) =>
`${featureName}/${actionName}`;

const actions = {
increment: createAction('foo/increment'),
Expand All @@ -22,7 +20,6 @@ describe(createSliceReducer.name, () => {
beforeEach(() => {
reducer = createSliceReducer(
initialState,
getter,
actions as any,
{
increment: (state) => {
Expand All @@ -33,7 +30,7 @@ describe(createSliceReducer.name, () => {
},
},
[
on<typeof initialState, [typeof double]>(double, (state) => ({
on(double, (state) => ({
...state,
foo: state.foo * 2,
})),
Expand Down
1 change: 0 additions & 1 deletion packages/ngrx-slice/src/lib/create-slice-reducer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ export function createSliceReducer<
CaseReducers extends SliceCaseReducers<SliceState> = SliceCaseReducers<SliceState>
>(
initialState: SliceState,
sliceActionNameGetter: SliceActionNameGetter,
actions: SliceActions<SliceState, CaseReducers>,
reducers: CaseReducers,
extraReducers?: SliceOptions<
Expand Down
7 changes: 4 additions & 3 deletions packages/ngrx-slice/src/lib/create-slice.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { createFeatureSelector } from '@ngrx/store';
import {createFeatureSelector, ActionCreator} from '@ngrx/store';
import type { Draft } from 'immer';
import { createSliceActions } from './create-slice-actions';
import { createSliceReducer } from './create-slice-reducer';
Expand Down Expand Up @@ -57,12 +57,11 @@ export function createSlice<
name,
sliceActionNameGetter,
reducers,
reducersToActions,
reducersToActions
);

const reducer = createSliceReducer<SliceState, SliceName, CaseReducers>(
initialState,
sliceActionNameGetter,
actions,
reducers,
extraReducers
Expand All @@ -88,6 +87,7 @@ export function createNamespacedSlice<
initialState,
reducers,
extraReducers,
reducersToActions,
sliceActionNameGetter = defaultSliceActionNameGetter,
}: SliceOptions<SliceName, SliceState, CaseReducers>): NamespacedSlice<
SliceState,
Expand All @@ -104,6 +104,7 @@ export function createNamespacedSlice<
initialState,
reducers,
extraReducers,
reducersToActions,
sliceActionNameGetter,
});

Expand Down

0 comments on commit 01c6687

Please sign in to comment.