feat: implement network connectivity monitor interface and mock service (#26)#28
Open
rohansaini-02 wants to merge 1 commit into
Open
Conversation
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.
Summary
Implementation of a decoupled Connectivity Monitor Utility Proof of Concept (PoC). This module introduces an interface-driven architecture for monitoring network states, ensuring the core application remains agnostic of underlying native network libraries.
Related Issue
Resolves #26
Problem Statement
The TAP Buddy application relies on accurate network state detection for critical features like the Offline Sync Engine and AI Tutor WebSockets. Hardcoding a specific library (like NetInfo) directly into these services creates tight coupling and makes unit testing network transitions (e.g., WiFi to Offline) impossible without a physical device.
Changes Made
poc-connectivitystandalone TypeScript package.INetworkServiceInterface: Defined a strict contract for network monitoring, including synchronous state retrieval and an observer pattern for changes.MockNetworkServiceImplementation: Created a robust mock service with helper methods (simulateOffline(),simulateOnline()) for environment simulation..gitignoreto keep the module structure clean and free of build artifacts.Technical Decisions
@react-native-community/netinfolater without modifying the Sync Engine.Testing Performed
isOnline()logic across various simulated states (WiFi, Cellular, None).unsubscribe()correctly removes listeners to prevent memory leaks.Results
A fully testable connectivity utility that provides the foundation for reliable offline-first syncing.
Checklist