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

Repositoryパターンを採用する #73

Open
aqua-ix opened this issue Mar 26, 2024 · 0 comments
Open

Repositoryパターンを採用する #73

aqua-ix opened this issue Mar 26, 2024 · 0 comments

Comments

@aqua-ix
Copy link
Owner

aqua-ix commented Mar 26, 2024

データソースへのアクセスを抽象化し、データの取得や保存のロジックをカプセル化する。

サンプルコード

class ChatRepository(private val dataSource: ChatDataSource) {
    suspend fun sendMessage(message: Message) {
        dataSource.send(message)
    }

    suspend fun getAllMessages(): List<Message> {
        return dataSource.getAllMessages()
    }
}

interface ChatDataSource {
    suspend fun send(message: Message)
    suspend fun getAllMessages(): List<Message>
}
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