-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Introduce RxJava-based Event Bus (#330)
* Add event bus * Integrate event bus * Remove auth status change listener and provider * Fix indentation in pom * Fix pom.xml indentation * Remove singleton implementation and add null check to post method * Move EventBroker access to Activator * Update event broker calls to go through Activator * Fix bug caused by null EventBroker most likely because Activator hasn't been intitialized yet * Fix bug caused by null EventBroker most likely because Activator hasn't been intitialized yet * Add event bus * Remove subscription and type introspection * Fix artifact versioning bug * Added test coverage for cleanup method (#310) * Add tests for EventBroker component * Delete accidental RemoteLspFetcherTest addition * Revert "Delete accidental RemoteLspFetcherTest addition" This reverts commit 15ae75a. * Remove implicit deduplication --------- Co-authored-by: Nicolas <[email protected]> Co-authored-by: Jonathan Breedlove <[email protected]>
- Loading branch information
1 parent
722fe4d
commit 283be03
Showing
19 changed files
with
254 additions
and
111 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
37 changes: 37 additions & 0 deletions
37
plugin/src/software/aws/toolkits/eclipse/amazonq/broker/EventBroker.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.broker; | ||
|
||
import io.reactivex.rxjava3.disposables.Disposable; | ||
import io.reactivex.rxjava3.functions.Consumer; | ||
import io.reactivex.rxjava3.schedulers.Schedulers; | ||
import io.reactivex.rxjava3.subjects.PublishSubject; | ||
import io.reactivex.rxjava3.subjects.Subject; | ||
import software.aws.toolkits.eclipse.amazonq.broker.api.EventObserver; | ||
|
||
public final class EventBroker { | ||
|
||
private final Subject<Object> eventBus = PublishSubject.create().toSerialized(); | ||
|
||
public <T> void post(final T event) { | ||
if (event == null) { | ||
return; | ||
} | ||
eventBus.onNext(event); | ||
} | ||
|
||
public <T> Disposable subscribe(final Class<T> eventType, final EventObserver<T> observer) { | ||
Consumer<T> consumer = new Consumer<>() { | ||
@Override | ||
public void accept(final T event) { | ||
observer.onEvent(event); | ||
} | ||
}; | ||
|
||
return eventBus.ofType(eventType) | ||
.observeOn(Schedulers.computation()) | ||
.subscribe(consumer); | ||
} | ||
|
||
} |
9 changes: 9 additions & 0 deletions
9
plugin/src/software/aws/toolkits/eclipse/amazonq/broker/api/EventObserver.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
// Copyright 2024 Amazon.com, Inc. or its affiliates. All Rights Reserved. | ||
// SPDX-License-Identifier: Apache-2.0 | ||
|
||
package software.aws.toolkits.eclipse.amazonq.broker.api; | ||
|
||
@FunctionalInterface | ||
public interface EventObserver<T> { | ||
void onEvent(T event); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 0 additions & 10 deletions
10
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/auth/AuthStatusChangedListener.java
This file was deleted.
Oops, something went wrong.
38 changes: 0 additions & 38 deletions
38
plugin/src/software/aws/toolkits/eclipse/amazonq/lsp/auth/AuthStatusProvider.java
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.