Order in which on_configuration_change events are processed?
Posted: Fri Apr 12, 2019 10:59 pm
I have a scenario where Mod A has a global Table, and Mod B wants to read items from Mod A's table with a remote interface and add new ones based on what it finds.
Mod A's on_configuration_change handler:
1 Check if Table exists.
2 If not, create Table and add default entries.
Mod B's on_configuration_change handler:
1 Read Table[item1] using Mod A's interface
2 Insert Table[item2] using Mod A's interface
I'm getting an error because when Mod A's on_configuration_changed event runs after Mod B's, Table[item1] might not exist. If it can't be read, then Table[item2] will never be written, and that will cause problems down the road even if I prevent Mod B from crashing by checking for nil.
It seems like adding Mod A as a dependency for Mod B fixes the problem. Is this the correct solution, or is it a coincidence and I should look for a better way?
Mod A's on_configuration_change handler:
1 Check if Table exists.
2 If not, create Table and add default entries.
Mod B's on_configuration_change handler:
1 Read Table[item1] using Mod A's interface
2 Insert Table[item2] using Mod A's interface
I'm getting an error because when Mod A's on_configuration_changed event runs after Mod B's, Table[item1] might not exist. If it can't be read, then Table[item2] will never be written, and that will cause problems down the road even if I prevent Mod B from crashing by checking for nil.
It seems like adding Mod A as a dependency for Mod B fixes the problem. Is this the correct solution, or is it a coincidence and I should look for a better way?