# 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);
       }
     }));
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://briebug.gitbook.io/ngrx-workshop/advanced-actions/deciders.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
