TinyRuleKit
Hot Reload
`RuleEngine` is immutable. Use `RuleEngineRef` when rules are stored in a JSON file and should be reloaded without restarting the application.
JAVA
RuleEngineRef<GameContext> rules = RuleEngineRef.fromJsonPath(
RuleEngine.builder(GameContext.class)
.conditions(GameRules::condition)
.actions(GameRules::action),
Path.of("rules.json"));
Fire the current snapshot:
JAVA
rules.fire(GameTrigger.PLAYER_JOINED, context);
Reload only if the file changed:
JAVA
boolean changed = rules.reloadIfChanged();
If reading or compiling the new file fails, the previous valid engine snapshot remains active.