Skip to content

Rename DI service selectors from selectXDep to injectXDep #31957

Description

@vojtatranta

Problem

Two unrelated things are both called select…:

  • Redux state selectorsselectIsAnalyticsEnabled(state), ~750 of them across the repo.
  • DI service selectorsselectDesktopAnalyticsDep(services), 25 of them, fed to useServices.

The word says nothing about which one you are looking at, and the stems collide: selectAnalytics… can mean "read analytics state" or "hand me the analytics service". A component using both reads like this today (SupportConsentPopover.tsx):

const isAnalyticsEnabled = useSelector(selectIsAnalyticsEnabled);
const { analytics } = useServices(selectDesktopAnalyticsDep);

Only the hook tells them apart, and the argument they take is not the same kind of thing at all: one reads a slice of the store, the other pulls a dependency out of the injected services. The Dep suffix is the only hint, and it is easy to miss at the end of a long name.

Proposal

Use inject for the DI side, keeping select for state:

const isAnalyticsEnabled = useSelector(selectIsAnalyticsEnabled);
const { analytics } = useServices(injectDesktopAnalytics);

inject says what actually happens — a dependency is injected — and the two can no longer be confused at a glance or by autocomplete. It also frees the Dep suffix: injectDesktopAnalytics reads better than injectDesktopAnalyticsDep, though keeping Dep would be a smaller change if the type names (DesktopAnalyticsDep) should stay aligned.

Scope

  • 25 exported select…Dep functions and their call sites.
  • createSelectDispatchDep / selectDispatchDep in @suite-common/redux-utils.
  • The dependency-injection skill, which documents the current convention.
  • Mechanical rename, no behaviour change; could ride along with an existing DI touch or be done in one pass.

Open questions

  • injectXDep or injectX? The type is XDep, so dropping the suffix breaks the name symmetry the skill asks for, but reads better.
  • Same treatment for the getter variants (useGetter) if any are named select….

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

  • Status
    🎯 To do

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions