Skip to content

Conversation

liamdebeasi
Copy link
Contributor

@liamdebeasi liamdebeasi commented Jan 15, 2024

Issue number: resolves #28826


What is the current behavior?

getLength used to be a public method on ion-nav. However, the @Method decorator was removed in 1d46973#diff-4b2ac275268173207c99a590b0ced8b67dc3d697815eb51a3c0546ee7cb0c0aeR429-L445.

While the removal of @Method from isAnimating was likely intentional, the team thinks that removing it from getLength was an accident. Otherwise, it's challenging to call methods like removeIndex if you don't know how many items are in the stack. For example, if a developer wants to remove the second to last item, they need to know how many items are in the stack so they don't give an index that is out of bounds.

What is the new behavior?

  • getLength is now a public method

Does this introduce a breaking change?

  • Yes
  • No

The team is considering this to be a breaking change. As part of this, getLength must return Promise<number> instead of number as all public methods must return promises. While this API wasn't documented by mistake, it's technically always been a public API. As a result, JS-only developers can access getLength synchronously and TypeScript developers can do the same if they typecast Nav as any. Given that the return signature is different, we are going to ship this in a major release.

Other information

@github-actions github-actions bot added the package: core @ionic/core package label Jan 15, 2024
@liamdebeasi liamdebeasi changed the title Fw 5890 fix(nav): getLength is part of the public API Jan 15, 2024
@liamdebeasi liamdebeasi marked this pull request as ready for review January 15, 2024 21:59
@liamdebeasi liamdebeasi requested review from sean-perkins and a team as code owners January 15, 2024 21:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
package: core @ionic/core package
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants