Introduce LoadSessionAsync for async scenarios #107
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.
What kind of change does this PR introduce?
Introduce the LoadSessionAsync to allow scenarios where LoadSession needs to load the session in an async way. In some cases it's not possible to load the session in a sync way, thus the introduction of this new method. I encountered a roadblock while trying to use this lib in a Blazor project, where the load session from local storage is done in an async way, and its not possible to force it to be sync.
What is the current behavior?
Currently its not possible to load session in an async way.
What is the new behavior?
Allow the session to be loaded asynchronously.
Additional context
I introduced an obsolete attribute to the LoadSession methods but redirected the LoadSessionAsync implementation to the LoadSession, to avoid breaking changes on existing consumers.
New consumers that want to use LoadSessionAsync should implement that method and disregard the old one, as it should be removed in the future.