Closed Bug 1851037 Opened 2 years ago Closed 9 months ago

Refactor `LoadUrlUseCase.invoke` to be an operator function

Categories

(Firefox for Android :: Browser Engine, task)

All
Android
task

Tracking

()

RESOLVED FIXED
134 Branch
Tracking Status
firefox134 --- fixed

People

(Reporter: lina, Assigned: anpopa, Mentored)

Details

(Keywords: good-first-bug)

Attachments

(1 file)

The LoadUrlUseCase.invoke method in the feature-session Android Component is declared as a regular fun, not an operator fun. That means we must invoke it explicitly, like this:

loadUrlUseCase.invoke(url)

If we declared invoke as an operator fun, we could invoke it using the more convenient function call syntax instead:

loadUrlUseCase(url)

For this bug, let's:

  1. Change the declaration of invoke to use operator fun.
  2. Ensure that all implementations of LoadUrlUseCase use override operator fun.
  3. Refactor all callers in all components to use the more convenient function call syntax, instead of explicitly calling .invoke().

This is a great first bug for getting started with Android and Kotlin development!

Thanks for noting that, and for the links; that's really good to know!

IMHO, invoke() looks better .

I think so, too 😊 Let's leave the nullable calls as usecase?.invoke(), but switch to usecase() for non-nullable calls—how does that sound?

Severity: -- → N/A
Component: General → Browser Engine
Assignee: nobody → anpopa
Attachment #9435807 - Attachment description: WIP: Bug 1851037 - changed fun to operator fun and refactored all callers to avoid explicitly call invoke → Bug 1851037 - changed fun to operator fun and refactored all callers to avoid explicitly call invoke
Pushed by anpopa@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/75c4613ada94 changed fun to operator fun and refactored all callers to avoid explicitly call invoke r=android-reviewers,avirvara
Pushed by anpopa@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/a5f9fda9fb3a changed fun to operator fun and refactored all callers to avoid explicitly call invoke r=android-reviewers,avirvara
Status: NEW → RESOLVED
Closed: 9 months ago
Resolution: --- → FIXED
Target Milestone: --- → 134 Branch
Flags: needinfo?(anpopa)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: