Split api & Impl for all `GetSearchUseCase`

Move `GetSearchUseCase` to `:core:domain:api` and then `DefaultGetSearchUseCase` to `:core:domain:impl`
pull/1740/head
Jordan Terry 9 months ago
parent bcd1b3f867
commit 224a43a318
No known key found for this signature in database

@ -84,6 +84,7 @@ dependencies {
implementation(projects.core.ui)
implementation(projects.core.designsystem)
implementation(projects.core.data)
implementation(projects.core.domain.di)
implementation(projects.core.model)
implementation(projects.core.analytics)
implementation(projects.sync.work)

@ -0,0 +1,17 @@
<?xml version="1.0" encoding="utf-8"?>
<!--
Copyright 2022 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<manifest />

@ -0,0 +1,29 @@
/*
* Copyright 2024 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.samples.apps.nowinandroid.core.domain
import com.google.samples.apps.nowinandroid.core.model.data.UserSearchResult
import kotlinx.coroutines.flow.Flow
/**
* A use case which returns the searched contents matched with the search query.
*/
interface GetSearchContentsUseCase {
operator fun invoke(
searchQuery: String,
): Flow<UserSearchResult>
}

@ -26,6 +26,7 @@ android {
dependencies {
api(projects.core.data)
api(projects.core.model)
api(projects.core.domain.api)
implementation(libs.javax.inject)

@ -17,9 +17,15 @@
package com.google.samples.apps.nowinandroid.core.domain
import dagger.Module
import dagger.Binds
import dagger.hilt.InstallIn
import dagger.hilt.components.SingletonComponent
@InstallIn(SingletonComponent::class)
@Module
interface DomainModule
interface DomainModule {
@Binds
fun bindGetSearchContentsUseCase(
impl: DefaultGetSearchContentsUseCase
): GetSearchContentsUseCase

@ -27,15 +27,12 @@ import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.combine
import javax.inject.Inject
/**
* A use case which returns the searched contents matched with the search query.
*/
class GetSearchContentsUseCase @Inject constructor(
class DefaultGetSearchContentsUseCase @Inject constructor(
private val searchContentsRepository: SearchContentsRepository,
private val userDataRepository: UserDataRepository,
) {
) : GetSearchContentsUseCase {
operator fun invoke(
override operator fun invoke(
searchQuery: String,
): Flow<UserSearchResult> =
searchContentsRepository.searchContents(searchQuery)

Loading…
Cancel
Save