Add optional ReactiveX adapter for device events#7
Draft
bruno-f-cruz wants to merge 2 commits into
Draft
Conversation
bruno-f-cruz
marked this pull request as draft
July 4, 2026 02:51
bruno-f-cruz
force-pushed
the
feat-device-event-logic
branch
from
July 17, 2026 20:20
eb7bb8b to
6863093
Compare
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Leaving this as a draft as it is a bit opinionated, but since I had this convo with @Poofjunior and @glopesdev separately, just putting it on a PR for future reference. This is how I would like to handle events from devices :P
Summary
tldr: reactive framework rocks — this is the optional Rx layer on top of the push-subscription API.
The core push-subscription API (
Device.subscribe,Device.subscribe_all, the dedicated event thread) has already landed onrefactor-unified-apidirectly, since it doesn't need ReactiveX. This PR is now scoped to just the optional Rx adapter on top of it.What changed
harp.device.rx) —observe(device, register)/observe_all(device)return hot, ref-counted (ops.share) Observables backed by a single underlyingDevice.subscribe/subscribe_allcall. Gated behind theharp-device[rx]extra; importing the module withoutreactivexraises a clearImportError. If I had it my way, we would only have this, but for now leaving it optional.scripts/event_monitor.pyshows the Rx adapter alongside the plainsubscribe_allAPI on a live device (COM3). (A non-Rx-only version of this example also lives atdocs/examples/subscribing_to_events/.)Notes
observe/observe_allemit on the device's shared event thread — useops.observe_on(scheduler)to move heavy downstream work off it.