[question] why not create helper extension functions?

Open
#1,927 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
25/100
Issue type
Refactor
Clarity
Needs clarification
Activity status
Stale
Tech stack
android, kotlin
Domain
mobile

Research direction

Review the repeated stateIn blocks in the ViewModels and the backgroundScope.launch(UnconfinedTestDispatcher()) collectors in tests. First determine whether the proposal has a defined API and scope; done would require an agreed design and documented examples or tests showing the resulting helper functions are appropriate.

Written by the indexing model from the issue text.

Description

Foe example in ViewModels there are a lot of very similar code

            }.stateIn(
                scope = viewModelScope,
                started = SharingStarted.WhileSubscribed(5_000),
                initialValue = SearchResultUiState.Loading,
            )

in tests there are backgroundScope.launch(UnconfinedTestDispatcher()) { viewModel.searchResultUiState.collect() }

so why not have extension functions to simplify it?

Dominant language
Kotlin
Stars
22.1k
Forks
4.7k
PR merge metrics
No merged PRs in 30d

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from android/nowinandroid

All issues in android/nowinandroid

Similar issues

More Kotlin issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.