The Ashley ECS framework typically does not control the loading or management of resources as this would usually be done separately by something like an asset manager or in a bespoke loader.
If however you have a bespoke loading system and are more interested in using Ashley to trigger the dispose methods you can use an EntityListener
Let's just say you have a textureComponent which is used to store the image for an enemy and when the enemy is removed you no longer need any references to that image and you want it disposed.
You would first make an EntityListener:
import com.badlogic.ashley.core.ComponentMapper;
import com.badlogic.ashley.core.Entity;
import com.badlogic.ashley.core.EntityListener;
public class TexturecompListener implements EntityListener{
@Override
public void entityAdded(Entity entity) {
}
@Override
public void entityRemoved(Entity entity) {
TextureComponent tc = ComponentMapper.getFor(TextureComponent.class).get(entity);
tc.region.getTexture().dispose();
}
}
Now you have a listener you need to add it to your engine with a family so it knows which entities this listener should be linked to:
engine.addEntityListener(
Family.all(TextureComponent.class).get(), // set which entities to call this lisneter for
new TexturecompListener()); // set the listener
This would then dispose the image when the entity is removed from the engine.