Skip to content

Commit

Permalink
chore(docs): Added payload interface options to migration docs
Browse files Browse the repository at this point in the history
Closes #303
  • Loading branch information
brandonroberts committed Aug 25, 2017
1 parent e4133a4 commit 18d1f82
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion MIGRATION.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,9 @@ import { compose } from '@ngrx/store';

### Action interface

The `payload` property has been removed from the `Action` interface.
The `payload` property has been removed from the `Action` interface. It was a source of type-safety
issues, especially when used with `@ngrx/effects`. If your interface/class has a payload, you need to provide
the type.

BEFORE:
```ts
Expand Down Expand Up @@ -79,6 +81,22 @@ export class MyEffects {
}
```

If you prefer to keep the `payload` interface property, you can provide your own parameterized version.

```ts
export interface ActionWithPayload<T> extends Action {
payload: T;
}
```

And if you need an unsafe version to help with transition.

```ts
export interface UnsafeAction implements Action {
payload?: any;
}
```

### Registering Reducers

Previously to be AOT compatible, it was required to pass a function to the `provideStore` method to compose the reducers into one root reducer. The `initialState` was also provided to the method as an object in the second argument.
Expand Down

0 comments on commit 18d1f82

Please sign in to comment.