-
Notifications
You must be signed in to change notification settings - Fork 1.3k
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
Observable Configs #1709
Comments
I thought of a number of Observable/Observer styles:
And potentially the config might even keep track of what an observer is interested in, notifying it only if the specific parameters an observer is interested in have changed. I don't know if we'd want that much responsibility in the Configs though. Thoughts? (p.s. would this be best discussed in the forum instead? I figured it's a bit of a feature request and opening an issue might not be entirely inappropriate) |
It might be more of a forum thing, yeah, but it sounds reasonable enough and might get more bites here than in the forum. Hard to say. Pinging @immortius @flo @MarcinSc for ideas |
I would recommend using the standard On 3 May 2015 at 07:21, Rasmus Praestholm notifications@github.com wrote:
|
What about config sending an exception on the world entity (or a separate "config" entity), since we are already event driven... |
I use an In contrast to Java's property change listeners it can be implemented by lambda expressions and you don't need use String constants for identification. I think it could make sense using that instead of the in-game event system, because the linking between Observer and Observable is fairly explicit and it works without the entity system (e.g. in the main menu). I'm planning to move some of the core functionality of WorldViewer over the next days here to improve the preview screen, and |
Hmm, the lambda support is a good point, and I agree events are not I think the PropertyChangeSupport approach is a better fit in this space
Yes, the PropertyChangeSupport requires string names for each property - Threading is a concern in both cases. I won't deny that PropertyChangeSupport is a bit annoying to integrate,
|
I don't think so, but this issue here is next up on my todo list. |
I'm currently working on part of this. I just went through the RenderingConfig and made both the instance itself and almost all its properties observable. I've eventually settled for the PropertyChangeSupport-based approach as there was already one usage of it in the class. I will go through the RenderingDebugConfig and do the same. I aim to submit a PR in the next 24/48 hours. Tagging @tdgunes and @indianajohn as it might be interesting for them. |
A small boost in performance in per-frame or per-update code could be achieved if instances of a class didn't have to look at config values unless they get notified that values have changed. The code too would also tend to be a little leaner.
For this purpose Configs could be made to implement an Observable interface (i.e. subscribe/unsubscribe methods - whatever is most common in Java or more specifically in Terasology) to register instances implementing an Observer interface and interested in being notified of a Config's changes.
The text was updated successfully, but these errors were encountered: