-
Notifications
You must be signed in to change notification settings - Fork 41
[ECO-5479][LiveObjects] Implement object lifecycle events #1151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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 hidden or 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
2 changes: 1 addition & 1 deletion
2
lib/src/main/java/io/ably/lib/objects/state/ObjectsStateEvent.java
This file contains hidden or 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
69 changes: 69 additions & 0 deletions
69
lib/src/main/java/io/ably/lib/objects/type/ObjectLifecycleChange.java
This file contains hidden or 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,69 @@ | ||
| package io.ably.lib.objects.type; | ||
|
|
||
| import io.ably.lib.objects.ObjectsSubscription; | ||
| import org.jetbrains.annotations.NonBlocking; | ||
| import org.jetbrains.annotations.NotNull; | ||
|
|
||
| /** | ||
| * Interface for managing subscriptions to Object lifecycle events. | ||
| * <p> | ||
| * This interface provides methods to subscribe to and manage notifications about significant lifecycle | ||
| * changes that occur to Object, such as deletion. More events can be added in the future. | ||
| * Multiple listeners can be registered independently, and each can be managed separately. | ||
| * <p> | ||
| * Lifecycle events are different from data update events - they represent changes | ||
| * to the object's existence state rather than changes to the object's data content. | ||
| * | ||
| * @see ObjectLifecycleEvent for the available lifecycle events | ||
| */ | ||
| public interface ObjectLifecycleChange { | ||
| /** | ||
| * Subscribes to a specific Object lifecycle event. | ||
| * | ||
| * <p>This method registers the provided listener to be notified when the specified | ||
| * lifecycle event occurs. The returned subscription can be used to | ||
| * unsubscribe later when the notifications are no longer needed. | ||
| * | ||
| * @param event the lifecycle event to subscribe to | ||
| * @param listener the listener that will be called when the event occurs | ||
| * @return a subscription object that can be used to unsubscribe from the event | ||
| */ | ||
| @NonBlocking | ||
| ObjectsSubscription on(@NotNull ObjectLifecycleEvent event, @NotNull ObjectLifecycleChange.Listener listener); | ||
|
|
||
| /** | ||
| * Unsubscribes the specified listener from all lifecycle events. | ||
| * | ||
| * <p>After calling this method, the provided listener will no longer receive | ||
| * any lifecycle event notifications. | ||
| * | ||
| * @param listener the listener to unregister from all events | ||
| */ | ||
| @NonBlocking | ||
| void off(@NotNull ObjectLifecycleChange.Listener listener); | ||
|
|
||
| /** | ||
| * Unsubscribes all listeners from all lifecycle events. | ||
| * | ||
| * <p>After calling this method, no listeners will receive any lifecycle | ||
| * event notifications until new listeners are registered. | ||
| */ | ||
| @NonBlocking | ||
| void offAll(); | ||
|
|
||
| /** | ||
| * Interface for receiving notifications about Object lifecycle changes. | ||
| * <p> | ||
| * Implement this interface and register it with an ObjectLifecycleChange provider | ||
| * to be notified when lifecycle events occur, such as object creation or deletion. | ||
| */ | ||
| @FunctionalInterface | ||
| interface Listener { | ||
| /** | ||
| * Called when a lifecycle event occurs. | ||
| * | ||
| * @param lifecycleEvent The lifecycle event that occurred | ||
| */ | ||
| void onLifecycleEvent(@NotNull ObjectLifecycleEvent lifecycleEvent); | ||
| } | ||
| } |
16 changes: 16 additions & 0 deletions
16
lib/src/main/java/io/ably/lib/objects/type/ObjectLifecycleEvent.java
This file contains hidden or 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,16 @@ | ||
| package io.ably.lib.objects.type; | ||
|
|
||
| /** | ||
| * Represents lifecycle events for an Ably Object. | ||
| * <p> | ||
| * This enum notifies listeners about significant lifecycle changes that occur to an Object during its lifetime. | ||
| * Clients can register a {@link ObjectLifecycleChange.Listener} to receive these events. | ||
| */ | ||
| public enum ObjectLifecycleEvent { | ||
| /** | ||
| * Indicates that an Object has been deleted (tombstoned). | ||
| * Emitted once when the object is tombstoned server-side (i.e., deleted and no longer addressable). | ||
| * Not re-emitted during client-side garbage collection of tombstones. | ||
| */ | ||
| DELETED | ||
| } |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.