-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
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
Support .run_if() on observers #14195
Comments
Just forwarding my thoughts from discord
|
This is one thing that makes the lack of support for run conditions on observers even more annoying. I just ran into this as well, where when I added the manual state check to the observer function, triggering it would cause a crash because a resource that would only exist in the specific state that observer was relevant in, correctly and as expected did not exist. To work around that I also had to wrap it in an option and use a let-else statement to unwrap it or return. |
My take:
So you couldn't use a run condition like I suspect that end-users of observers will keep meeting the lack of run condition support with disappointment. |
I do think that systems not running if one of their required resources doesn't exist would be a good thing btw, I've brought it up before: #12660 (comment). |
What problem does this solve or what need does it fill?
Just like with systems, sometimes observers are only relevant for a specific state. It would be much more convenient to be able to do this on observers using .run_if() or something similar, than having to manually check the state in the function code.
What solution would you like?
To be able to use .run_if() on observers to limit when they will run, just like on regular systems.
The text was updated successfully, but these errors were encountered: