Relaoding Expression Function when the module is reloaded?

In a gateway module Hook, we can add expression Function:

@Override
	public void configureFunctionFactory(ExpressionFunctionManager factory) {
		factory.getCategories().add(FUNCTION_CATEGORY);
		factory.addFunction(FUNCTION_MY_EXPRESSION, FUNCTION_CATEGORY, new MyExpressionFunction());
}

But when the module is reloaded it seems Ignition keep using the old expression function (especially for expression in gateway scope) until gateway is restarted.

Is there any way to unregister/register the new function ?

perhaps, @PGriffith will have an idea or explanation about it ?

I've never run into this, but it's quite plausible that we're holding on to things in memory. Are you overriding copy() on your implementation, by any chance?

Either way, we're probably not going to fix this. Module hot loading is entirely gone in 8.3 and this is such a minor thing it'd never make prioritization for 8.1.

I have not override copy.
It's indeed a corner case that will not possible in 8.3. The issue is due to a special use case of expression function...
Thanks for the explanation !

Any expression function that does polling or otherwise carries per-usage state must override .copy(). Only pure functions can use a singleton.

But I'm pretty sure that even old versions of singletons get stuck in expression tags.

3 Likes