package depart.frontal.taches;


import depart.frontal.donnees.DonneesVueB;
import depart.frontal.vues.VueB;

import static ca.ntro.app.tasks.frontend.FrontendTasks.*;

import ca.ntro.app.tasks.frontend.FrontendTasks;


public class TachesE {
	
	public static void creerTaches(FrontendTasks tasks) {
		
		creerDonneesVueB(tasks);

		tasks.taskGroup("TachesE")
		
		     .waitsFor(created(DonneesVueB.class))

		     .contains(subTasks -> {
		    	 
		    	 tacheE2(subTasks);

		     });
	}

	private static void creerDonneesVueB(FrontendTasks tasks) {

		tasks.task(create(DonneesVueB.class))

		     .waitsFor("tacheC2")
		     
		     .executesAndReturnsValue(inputs -> {
		    	 
		    	 var objA = new DonneesVueB();

		    	 return objA;

		     });
	}

	private static void tacheE2(FrontendTasks tasks) {
		
		tasks.task("tacheE2")

		     .waitsFor("tacheC2")

			 .waitsFor(clock().nextTick())

			 .waitsFor(created(DonneesVueB.class))
			 
			 .waitsFor(created(VueB.class))

		     .executes(inputs -> {
		    	 
		    	 var objA = inputs.get(created(VueB.class));
		    	 var objB = inputs.get(created(DonneesVueB.class));
		    	 var objC = inputs.get(clock().nextTick());
		    	 
		    	 objB.methodeA(objC.elapsedTime());
		    	 objB.methodeB(objA);

		     });
	}

}