Skip to content

feat(effects): add mapToAction operator#1822

Merged
brandonroberts merged 13 commits into
ngrx:masterfrom
alex-okrushko:map-to-action
May 15, 2019
Merged

feat(effects): add mapToAction operator#1822
brandonroberts merged 13 commits into
ngrx:masterfrom
alex-okrushko:map-to-action

Conversation

@alex-okrushko

Copy link
Copy Markdown
Member

PR Checklist

Please check if your PR fulfills the following requirements:

PR Type

What kind of change does this PR introduce?

Introduces mapToAction operator that can take either the config object, or 2 parameters: project and error.

config has the following interface:

/** Represents config with named paratemeters for mapToAction */
export interface MapToActionConfig<
  InputAction extends Action,
  OutputAction extends Action,
  ErrorAction extends Action,
  CompleteAction extends Action,
  UnsubscribeAction extends Action
> {
  // Project function that produces the output actions in success cases
  project: (action: InputAction, index: number) => Observable<OutputAction>;
  // Error handle function for project
  error: (error: any, action: InputAction) => ErrorAction;
  // Optional complete action provider
  // count is the number of actions project emitted before completion
  // action is the action that was completed
  complete?: (count: number, action: InputAction) => CompleteAction;
  // Optional flattening operator
  operator?: <InputAction, OutputAction>(
    project: (input: InputAction, index: number) => Observable<OutputAction>
  ) => OperatorFunction<InputAction, OutputAction>;
  // Optional unsubscribe action provider
  // count is the number of actions project emitted before unsubscribing
  // action is the action that was unsubscribed from
  unsubscribe?: (count: number, action: InputAction) => UnsubscribeAction;
}
[ ] Bugfix
[x] Feature
[ ] Code style update (formatting, local variables)
[ ] Refactoring (no functional changes, no api changes)
[ ] Build related changes
[ ] CI related changes
[ ] Documentation content changes
[ ] Other... Please describe:

What is the current behavior?

Closes # #1224

What is the new behavior?

Does this PR introduce a breaking change?

[ ] Yes
[x] No

Other information

@ngrxbot

ngrxbot commented May 5, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 29e89c6 at https://previews.ngrx.io/pr1822-29e89c6/

@alex-okrushko

Copy link
Copy Markdown
Member Author

Waiting for #1795 to be merged, so I can adjust the path of NotificationKind - removing it from internal.

@ngrxbot

ngrxbot commented May 6, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 388ca02 at https://previews.ngrx.io/pr1822-388ca02/

Comment thread modules/effects/src/map_to_action.ts Outdated
@ngrxbot

ngrxbot commented May 7, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 96654cf at https://previews.ngrx.io/pr1822-96654cf/

@alex-okrushko alex-okrushko self-assigned this May 7, 2019
@ThomasBurleson

Copy link
Copy Markdown
Contributor

@alex-okrushko - should this include a README or docs on (a) Benefits and (b) How to use it ?

Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
Comment thread modules/effects/src/map_to_action.ts Outdated
@ngrxbot

ngrxbot commented May 9, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 946f828 at https://previews.ngrx.io/pr1822-946f828/

@alex-okrushko

Copy link
Copy Markdown
Member Author

FYI, I'm adding docs for this PR ATM.

@ngrxbot

ngrxbot commented May 13, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 43cba13 at https://previews.ngrx.io/pr1822-43cba13/

@timdeschryver timdeschryver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Feedback on the docs

Comment thread projects/ngrx.io/content/guide/effects/index.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/index.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/index.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/operators.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/operators.md
Comment thread projects/ngrx.io/content/guide/effects/operators.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/operators.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/operators.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/operators.md Outdated
Comment thread projects/ngrx.io/content/guide/effects/operators.md Outdated
alex-okrushko and others added 5 commits May 14, 2019 10:37
Co-Authored-By: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-Authored-By: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-Authored-By: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
Co-Authored-By: Tim Deschryver <28659384+timdeschryver@users.noreply.github.com>
@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 2629f1a at https://previews.ngrx.io/pr1822-2629f1a/

@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for bfce944 at https://previews.ngrx.io/pr1822-bfce944/

@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 090e6c9 at https://previews.ngrx.io/pr1822-090e6c9/

@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for bfce944 at https://previews.ngrx.io/pr1822-bfce944/

@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 090e6c9 at https://previews.ngrx.io/pr1822-090e6c9/

@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for c5e6f99 at https://previews.ngrx.io/pr1822-c5e6f99/

1 similar comment
@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for c5e6f99 at https://previews.ngrx.io/pr1822-c5e6f99/

@ngrxbot

ngrxbot commented May 14, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for f248946 at https://previews.ngrx.io/pr1822-f248946/

@ngrxbot

ngrxbot commented May 15, 2019

Copy link
Copy Markdown
Collaborator

Preview docs changes for 2369f9e at https://previews.ngrx.io/pr1822-2369f9e/

@timdeschryver timdeschryver left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

@brandonroberts brandonroberts merged commit 1ff986f into ngrx:master May 15, 2019
@alex-okrushko alex-okrushko deleted the map-to-action branch October 30, 2019 03:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants