From 5d66ea65823e13ceb1eb8b995acff6cac9bf391d Mon Sep 17 00:00:00 2001 From: Paldiu Date: Thu, 15 Dec 2022 00:13:09 -0600 Subject: [PATCH] Update README.md --- README.md | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/README.md b/README.md index d92235a..c1e58ac 100644 --- a/README.md +++ b/README.md @@ -95,12 +95,29 @@ scheduler.getServiceManager().subscribe(manager -> { manager.emptyBukkitServicePool("pool_name", this).subscribe(pool -> { Set dispos = new HashSet<>(); + firstService = new YourFirstService(pool, "first_service_name"); secondService = new YourSecondService(pool, "second_service_name", 20 * 60L); thirdService = new YourThirdService(pool, "third_service_name", 20 * 60L, 20 * 60 * 10L, true, false); + scheduler.queue(firstService).subscribe(dispos::add); scheduler.queue(secondService).subscribe(dispos::add); scheduler.queue(thirdService).subscribe(dispos::add); + + disposables = Flux.fromIterable(dispos); }); }); + } + ``` + + You can then stop, cancel, and/or dispose of the tasks in your `JavaPlugin#onDisable()` method by calling: + ```Java + @Override + public void onDisable() { + scheduler.getServiceManager().subscribe(manager -> { + manager.getServicePools().doOnEach(signal -> Objects.requireNonNull(signal.get()) + .stopServices(disposables) + .subscribe()); + }); + } ```