Skip to content

Conversation

gpunto
Copy link
Contributor

@gpunto gpunto commented Sep 24, 2025

Goal

We're going to put a layer between WS events/backend responses and actual state updates. This layer is represented by StateUpdateEvent. So the logic will be:

  • We receive a WS event -> we map it to the corresponding StateUpdateEvent and forward it
  • We execute an API call and receive a response -> we create the appropriate StateUpdateEvents and forward it
  • All handlers will handle StateUpdateEvents, so they will react to both scenarios above

Why?

Because at the moment, if we're not receiving socket events, the various entity aren't propagating updates on operations executed by the SDK. For example, let's say we are not watching a feed and we execute activity.addCommentReaction. Then, only that Activity instance's state will be updated and nothing else (e.g. we could have other Activity instances containing the same comment, or a CommentList instance, etc).

So the changes that start with this PR will address these cases.

Ref iOS PR: GetStream/stream-feeds-swift#15

Implementation

  • Add StateUpdateEvent & the first few children
  • Add a StateUpdateEventListener to propagate/receive StateUpdateEvents
  • Create & pass StreamSubscriptionManager<StateUpdateEventListener> together/in place of the WS-related one

Testing

Everything should work as before + if we have multiple ActivityCommentList instances watching the same comments, and we do operations through Activity affecting those comments, they should be reflected in each instance.

Checklist

  • Issue linked (if any)
  • Tests/docs updated
  • I have signed the Stream CLA (required for external contributors)

@gpunto gpunto requested a review from Copilot September 24, 2025 14:55
Copy link
Contributor

github-actions bot commented Sep 24, 2025

PR checklist ✅

All required conditions are satisfied:

  • Title length is OK (or ignored by label).
  • At least one pr: label exists.
  • Sections ### Goal, ### Implementation, and ### Testing are filled.

🎉 Great job! This PR is ready for review.

Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR introduces a StateUpdateEvent system to create a layer between WebSocket events/backend responses and state updates, ensuring that state changes propagate across all SDK instances regardless of WebSocket subscription status.

  • Adds StateUpdateEvent sealed interface with comment-related event types
  • Introduces StateUpdateEventListener and subscription management for state events
  • Migrates ActivityCommentList to consume StateUpdateEvents instead of direct WebSocket events

Reviewed Changes

Copilot reviewed 18 out of 18 changed files in this pull request and generated no comments.

Show a summary per file
File Description
StateUpdateEvent.kt Defines the sealed interface for state update events and WebSocket event mapping
StateUpdateEventListener.kt Interface for listening to state update events
StateUpdateListenerExtensions.kt Extension functions for notifying listeners
ActivityCommentListEventHandler.kt Migrated from WebSocket events to StateUpdateEvent handling
ActivityImpl.kt Updated to emit StateUpdateEvents when performing comment operations
ActivityCommentListImpl.kt Changed subscription manager type from WebSocket to state events
CommentsRepository*.kt Modified return types to include full CommentData instead of just IDs
FeedsClientImpl.kt Added state event subscription manager and event forwarding
Create.kt Added state events subscription manager creation
Test files Updated test setup and assertions to work with new event system

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@gpunto gpunto added the pr:new-feature New feature label Sep 24, 2025
Copy link
Contributor

SDK Size Comparison 📏

SDK Before After Difference Status
stream-feeds-android-client 2.46 MB 2.46 MB 0.00 MB 🟢

@gpunto gpunto marked this pull request as ready for review September 24, 2025 15:21
@aleksandar-apostolov aleksandar-apostolov merged commit ca594d0 into develop Sep 25, 2025
6 of 7 checks passed
@aleksandar-apostolov aleksandar-apostolov deleted the state-events-1 branch September 25, 2025 08:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:new-feature New feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants