Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upInconsistent API in state params that are functions #1641
Closed
Comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
When a state has a default parameter that is a function, the function is invoked, and the param is set to the return value of that function.
However, if you pass a function as a param like so
That function does not get invoked and its return assigned as the param value. Rather, it is available as a function on the
$stateParamsobject. This is a powerful way to provide a state with a callback (see #1640) when navigating to it from a certain context.Both use-cases are valuable, but API consistency is desirable, and I wanted to confirm that it's not a bug. Perhaps an option could be added to the param config object?
Another possibility is to require an IIFE if you want a function that returns a value for setting on the param: