Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ho to avoid 'Selector has alread been set'? #252

Closed
handcraftedsource opened this issue Jan 18, 2022 · 5 comments · Fixed by #263
Closed

Ho to avoid 'Selector has alread been set'? #252

handcraftedsource opened this issue Jan 18, 2022 · 5 comments · Fixed by #263
Milestone

Comments

@handcraftedsource
Copy link

I used the new feature IStateSelector<TState, TValue>.

I have called Select in OnInitializedAsync of the Component on the injected property. The component is instantiated multiple times. If I switch from the first to the second component, I get an exception.

Is there any way to determine if selector is already set?

@mrpmorris
Copy link
Owner

OnInitializedAsync is being executed multiple times on the same object instance?

@handcraftedsource
Copy link
Author

I have a small example here that can be used to reproduce the behavior. Just start the application and switch to the counter page.

https://github.com/handcraftedsource/selector-exception-sample

Another thing I noticed: it seems like I can't use IStateSelection alone, the component needs to have IState injected as well.

mrpmorris added a commit that referenced this issue Jan 30, 2022
@mrpmorris mrpmorris added this to the 5.1 milestone Jan 30, 2022
@mrpmorris
Copy link
Owner

mrpmorris added a commit that referenced this issue Feb 1, 2022
@mrpmorris mrpmorris linked a pull request Feb 1, 2022 that will close this issue
@mrpmorris
Copy link
Owner

Could you try 5.1.0-Beta1 and let me know if it solves your problem?

@handcraftedsource
Copy link
Author

Yes the problem seems to be fixed with this version. Thanks for the quick fix. 👍

mrpmorris added a commit that referenced this issue Mar 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants