Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
@SpringBootApplication
public class MainApplication implements CommandLineRunner {
public static void main(String[] args) {
SpringApplication.run(MainApplication.class, args);
}
@Override
public void run(String... strings) throws Exception
{
System.out.println("==== started the MainApplication");
Subject subject = new Subject();
//Subscribing ObserverA
ObserverA observerA = new ObserverA();
subject.subscribe(observerA);
//Subscribing ObserverB
ObserverB observerB = new ObserverB();
subject.subscribe(observerB);
//ObserverC remain as unsubscribed
subject.setStatus("Started");
System.out.println("\n");
subject.setStatus("In-Progress");
System.out.println("\n");
subject.setStatus("Completed");
System.out.println("==== completed the MainApplication");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.