package speiger.src.coreengine.assets.base;

import java.util.concurrent.CompletableFuture;
import java.util.concurrent.Executor;

public interface IReloadableAsset {
	public String getName();
	public CompletableFuture<Void> reloadAssets(IAssetProvider provider, IReloadSyncer syncer, Executor offthreadExectutor, Executor syncExecutor);
	public void destroy();
	
	public static interface IReloadSyncer {
		public <T> CompletableFuture<T> sync(T value);
	}
	
	public static interface ISimpleRealodableAsset extends IReloadableAsset {
		@Override
		default CompletableFuture<Void> reloadAssets(IAssetProvider provider, IReloadSyncer syncer, Executor offthreadExectutor, Executor syncExecutor) {
			return syncer.sync(null).thenRunAsync(() -> onAssetsReloaded(provider), syncExecutor);
		}
		
		public void onAssetsReloaded(IAssetProvider provider);
	}
}
