# Deciders

* **Decides if this effect should process this action (ofType)**
* **Can map an action to a different action**

## Content Deciders

* **Inspect the payload to decide how to process action**
* **Can inspect payloads,  environmental variables, or store values.**
* **Can map an action to a different action based on payload**

```typescript
@Effect()
 save = this.actions$.pipe(
   ofType<SaveUser>(UserActionTypes.SaveUser),
   map(action => {
     if (action.payload.user.id > 0) {
       return new UpdateUser(action.payload);
     } else {
       return new InsertUser(action.payload);
     }
   })
 );

```

```typescript
// Effect store based decider
 @Effect()
 save = this.actions$.pipe(
   ofType<LoadUserById>(UserActionTypes.SaveUser),
   withLatestFrom(this.store.pipe(select(getSelectedUserId))),
     map(([action, userId]) => {
       if (userId > 0) {
         return new UpdateUser(action.payload);
       } else {         
         return new InsertUser(action.payload);
       }
     }));
```
