-
-
Notifications
You must be signed in to change notification settings - Fork 267
feat(ramps): add option to make requests without updating controller state #7708
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
…geolocation and countries, add countries to state, and create hydrateStore() for providers/tokens
…/core into TRAM-3231-no-state-update-options
…/core into TRAM-3231-no-state-update-options
This suggests a design flaw. These methods shouldn't be on the controller at all, they should be on a service class independent of the controller. IMO allowing the caller to skip "updating state" makes for a confusing API, as now the caller is forced to take responsibility for controller internals. APIs should encapsulate complexity/responsibility rather than thrust it upon the caller; It's the controller's job to manage its own state. |
Explanation
This PR adds a
doNotUpdateStateoption toExecuteRequestOptionsthat enables external consumers to use RampsController methods without modifying the controller's state.doNotUpdateState?: booleantoExecuteRequestOptionsinRequestCache.tsCacheOptionstype for stateful methods (init,setUserRegion,hydrateState) that should not acceptdoNotUpdateStategetCountries(),getTokens(),getProviders(), andgetPaymentMethods()to conditionally skip state updates whendoNotUpdateState: trueUse 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:References
https://consensyssoftware.atlassian.net/browse/TRAM-3231
Checklist
Note
Introduces an opt-in way to call RampsController fetchers without touching controller state, useful for ad‑hoc comparisons or alternate views.
doNotUpdateStatetoExecuteRequestOptionsand newCacheOptionstype; updates signatures forinit(),setUserRegion(),hydrateState(), and trigger methods accordinglygetCountries(),getTokens(),getProviders(), andgetPaymentMethods()to skip state writes whendoNotUpdateState: truewhile still updating the request cache (dedup remains intact)CacheOptions; adjusts tests to cover non-mutating behavior and cache updates; minor import additions (createCacheKey)Written by Cursor Bugbot for commit 84ae67d. This will update automatically on new commits. Configure here.