Skip to content

feat: implement event subscription in UniFFI bridge#48

Merged
xdustinface merged 1 commit intov0.42-devfrom
claude/issue-46-20260314-0023
Mar 14, 2026
Merged

feat: implement event subscription in UniFFI bridge#48
xdustinface merged 1 commit intov0.42-devfrom
claude/issue-46-20260314-0023

Conversation

@xdustinface
Copy link
Owner

Closes #46

Adds subscribe and unsubscribe methods to SpvClient in the UniFFI bridge so that foreign consumers (React Native / Swift) can receive real-time sync progress, peer-connection, and transaction events.

Changes

  • SpvClient stores a Mutex<Option<JoinHandle<()>>> for the active subscription
  • subscribe(listener: Arc<dyn SpvEventListener>) spawns a background tokio task that reads from sync, network, and progress channels
  • unsubscribe() aborts the background task
  • convert_sync_event and convert_network_event helpers map internal types to bridge types
  • 5 new unit tests covering subscription lifecycle and full event conversion

@github-actions
Copy link

This PR has merge conflicts with the base branch. Please rebase or merge the base branch into your branch to resolve them.

Adds event subscription support to the SpvClient wrapper in the UniFFI
bridge module so foreign consumers (React Native / Swift) can receive
real-time sync progress, peer-connection, and transaction events.

Changes:
- Add subscription_handle field to SpvClient to store the background JoinHandle
- Add subscribe(listener) method that spawns a background tokio task reading
  from the inner client's broadcast channels and forwarding converted events
- Add unsubscribe() method that aborts the background task
- Add convert_sync_event helper (MempoolActivated maps to None)
- Add convert_network_event helper for all three NetworkEvent variants
- Add unit tests for subscribe/unsubscribe lifecycle and event conversion

Co-authored-by: Kevin Rombach <xdustinface@users.noreply.github.com>
@xdustinface xdustinface force-pushed the claude/issue-46-20260314-0023 branch from 8aee4f6 to 7c03d64 Compare March 14, 2026 00:38
@xdustinface xdustinface merged commit baab810 into v0.42-dev Mar 14, 2026
49 of 52 checks passed
@xdustinface xdustinface deleted the claude/issue-46-20260314-0023 branch March 14, 2026 00:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: implement event subscription in UniFFI bridge

1 participant