Skip to content

Conversation

@georgeweiler
Copy link
Contributor

@georgeweiler georgeweiler commented Jan 23, 2026

Explanation

This PR adds a doNotUpdateState option to ExecuteRequestOptions that enables external consumers to use RampsController methods without modifying the controller's state.

  • Added doNotUpdateState?: boolean to ExecuteRequestOptions in RequestCache.ts
  • Added CacheOptions type for stateful methods (init, setUserRegion, hydrateState) that should not accept doNotUpdateState
  • Updated getCountries(), getTokens(), getProviders(), and getPaymentMethods() to conditionally skip state updates when doNotUpdateState: true
  • The option is passed through method signatures including all trigger methods
  • Request caching and deduplication still work normally - only the domain state updates are skipped

Use Case

External teams consuming the RampsController may need to call API methods (e.g., getTokens, getProviders) to fetch data for display or comparison purposes without polluting the controller's persisted state. For example:

// Fetch tokens for a different region without affecting the user's current state
const otherRegionTokens = await rampsController.getTokens('fr', 'buy', {
  doNotUpdateState: true,
});

References

https://consensyssoftware.atlassian.net/browse/TRAM-3231

Checklist

  • I've updated the test suite for new or updated code as appropriate
  • I've updated documentation (JSDoc, Markdown, etc.) for new or updated code as appropriate
  • I've communicated my changes to consumers by updating changelogs for packages I've changed
  • I've introduced breaking changes in this PR and have prepared draft pull requests for clients and consumer packages to resolve them

Note

Introduces an opt-in way to call RampsController fetchers without touching controller state, useful for ad‑hoc comparisons or alternate views.

  • Adds doNotUpdateState to ExecuteRequestOptions and new CacheOptions type; updates signatures for init(), setUserRegion(), hydrateState(), and trigger methods accordingly
  • Updates getCountries(), getTokens(), getProviders(), and getPaymentMethods() to skip state writes when doNotUpdateState: true while still updating the request cache (dedup remains intact)
  • Exports CacheOptions; adjusts tests to cover non-mutating behavior and cache updates; minor import additions (createCacheKey)
  • Updates changelog with the new option

Written by Cursor Bugbot for commit 84ae67d. This will update automatically on new commits. Configure here.

@georgeweiler georgeweiler changed the base branch from main to TRAM-3230-controller-init-reorg January 23, 2026 16:40
Base automatically changed from TRAM-3230-controller-init-reorg to main January 23, 2026 22:53
@georgeweiler georgeweiler marked this pull request as ready for review January 23, 2026 23:32
@georgeweiler georgeweiler requested review from a team as code owners January 23, 2026 23:32
@georgeweiler georgeweiler changed the title Tram 3231 no state update options feat(ramps): add option to make requests without updating controller state Jan 23, 2026
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.

2 participants