Skip to content
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

[WIP] Version 6.0 proposal #171

Open
SumeraMartin opened this issue Nov 4, 2022 · 0 comments
Open

[WIP] Version 6.0 proposal #171

SumeraMartin opened this issue Nov 4, 2022 · 0 comments
Assignees
Milestone

Comments

@SumeraMartin
Copy link
Member

SumeraMartin commented Nov 4, 2022

Seems like that with the adoption of Jetpack Compose, we started to use only cr-usecases and core packages and other packages are not actively used anymore. I think that the next step should be version 6.0.0 where we will remove unused packages and perform refactoring of the new ones.

interface UseCase<INPUT, OUTPUT> {

    suspend fun run(input: INPUT): OUTPUT
}

interface FlowUseCase<INPUT, OUTPUT> {

    fun <OUTPUT> create(input: INPUT): Flow<OUTPUT>
}

interface UseCaseExecutor {

    fun <INPUT, OUTPUT> UseCase<INPUT, OUTPUT>.execute(): OUTPUT
}

interface BetterUseCaseExecutor : UseCaseExecutor {

    fun <INPUT, OUTPUT> UseCase<INPUT, OUTPUT>.executeOnMainDispatcher(): OUTPUT
}

interface EventObserver {

    fun sendEvent(event: String)

    fun observeEvents(callback: (String) -> Unit)
}

class TestUseCase : UseCase<Int, String> {

    override suspend fun run(input: Int): String {
        return input.toString()
    }
}

class TestViewModel(
    private val testUseCase: TestUseCase,
    useCaseExecutor: UseCaseExecutor,
    eventObserver: EventObserver,
) : UseCaseExecutor by useCaseExecutor, EventObserver by eventObserver {

    fun test() {
        testUseCase.execute()

        sendEvent("")
    }
}
@SumeraMartin SumeraMartin self-assigned this Nov 4, 2022
@SumeraMartin SumeraMartin added this to the 6.0.0 milestone Nov 4, 2022
@SumeraMartin SumeraMartin changed the title Version 6.0 proposal [WIP] Version 6.0 proposal Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant