[SDK-2744] Delay restoring state until necessary, rather than in constructor/initialization #550
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Changes
A community bug report came in (#543) that reported a bug relating to how some frameworks support lazy loading of classes, and the fact that we restore the end-user state via cookies within the
Auth0\SDK\Auth0
constructor, during initialization. I'd not seen this reported before, but I definitely see the benefit of changing this behavior to avoid this sort of side effect.I've opened this PR resolving this issue by avoiding invoking restoreState() until right before necessary. All references to the private
state
var have been replaced with calls to thegetState()
method, which replacesrestoreState()
, which will restore the state when necessary if it has not already been done so by a preceeding call. This is a cleaner approach anyway.References
Resolves #543
Contributor Checklist