Skip to content

@ngrx/operators: Add migration for deprecated tapResponse signature #4841

Open
@markostanimirovic

Description

@markostanimirovic

Which @ngrx/* package(s) are relevant/related to the feature request?

operators

Information

The tapResponse signature that accepts a sequence of callbacks:

tapResponse<T>(
  next: (value: T) => void,
  error: (error: unknown) => void,
  complete?: () => void
)

will be deprecated in v20 in favor of another tapResponse signature that accepts the observer object:

tapResponse<T>(observer: {
  next: (value: T) => void;
  error: (error: unknown) => void;
  complete?: () => void;
  finalize?: () => void;
})

Provide a schematic that migrates from deprecated to the tapResponse signature with the observer object. It should support the following cases:

  1. The most common:
// from:
tapResponse(() => next, () => error)

// to:
tapResponse({ next: () => next, error: () => error })

// from:
tapResponse(() => next, () => error, () => complete)

// to:
tapResponse({ next: () => next, error: () => error, complete: () => complete })
  1. When the tapResponse operator is aliased:
import { tapResponse as myTapResponse } from '@ngrx/operators';

// from:
myTapResponse(() => next, () => error)

// to:
myTapResponse({ next: () => next, error: () => error })

// from:
myTapResponse(() => next, () => error, () => complete)

// to:
myTapResponse({ next: () => next, error: () => error, complete: () => complete })
  1. When namespace import is used:
import * as operators from '@ngrx/operators';

// from:
operators.tapResponse(() => next, () => error)

// to:
operators.tapResponse({ next: () => next, error: () => error })

// from:
operators.tapResponse(() => next, () => error, () => complete)

// to:
operators.tapResponse({ next: () => next, error: () => error, complete: () => complete })

Describe any alternatives/workarounds you're currently using

No response

I would be willing to submit a PR to fix this issue

  • Yes
  • No

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions