Skip to content

fix: improve rxRequest API ergonomics with function overloads#71

Closed
michaelbe812 wants to merge 1 commit into
mainfrom
fix/improve-rx-request-api-ergonomics
Closed

fix: improve rxRequest API ergonomics with function overloads#71
michaelbe812 wants to merge 1 commit into
mainfrom
fix/improve-rx-request-api-ergonomics

Conversation

@michaelbe812

Copy link
Copy Markdown
Owner

Summary

  • Implements function overloads for rxRequest to improve API ergonomics
  • Eliminates unsafe type casting when no trigger is provided
  • Provides better type safety and developer experience

Related Issue

Fixes #53

Changes Made

API Improvements

  • Added two distinct function overloads:
    • No-trigger case: requestFn: () => Observable
    • With-trigger case: requestFn: (arg: A) => Observable
  • Created separate type definitions for each overload scenario
  • Removed unsafe 'undefined as A' type casting from implementation

Type Safety

  • Proper type inference for both usage patterns
  • No more forced parameters that aren't actually used
  • Clean separation of concerns between triggered and non-triggered requests

Testing

  • Added comprehensive tests for both overload cases
  • Verified type inference works correctly
  • All existing tests pass, confirming backward compatibility
  • Added 3 new test cases specifically for overload type safety

Breaking Changes

None - this change is fully backward compatible. It only adds function overloads without removing any existing functionality.

Testing Checklist

  • All existing tests pass
  • New tests added for overloads
  • Type checking passes
  • Linting passes
  • Test suite passes

- Add function overloads for better type safety when no trigger is provided
- Remove unsafe 'undefined as A' casting from implementation
- Separate types for with-trigger and without-trigger cases
- Add comprehensive tests for both overload scenarios
- Maintain full backward compatibility with existing code

Fixes #53
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.

Improve rxRequest API ergonomics by removing forced casting

1 participant