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

Template values are not available by auto-update #2

Open
tc33 opened this issue Sep 1, 2013 · 0 comments
Open

Template values are not available by auto-update #2

tc33 opened this issue Sep 1, 2013 · 0 comments

Comments

@tc33
Copy link
Owner

tc33 commented Sep 1, 2013

The problem is that when a Template is set, the config event that's fired is for the Template.KEY ConfigKey. So any class using the auto-update idiom will not update their values for config keys within the template. If the template hasn't already been set before the object (that's using the idiom) is constructed, then the object won't be configured with the template values. This leaves them unset even when there's a value set in the template.

It's not sufficient to just use a convention where the template is set before any other configuration to make sure the template is available. This is because some of the objects created in the template may themselves be dependent on other things in the template (e.g. Initialiser component and Initialiser.METHOD).

One (imperfect) solution is to always add Template.KEY to the fields that trigger a reconfiguration in the auto-update idiom, like this:

public void onEvent(ConfigEvent event) {
if (event.isKindOf(Template.KEY, RandomSequence.RANDOM_SEQUENCE)) {
setup();
}
}

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

No branches or pull requests

1 participant