@@ -45,11 +45,8 @@ UseCases are protocols which do one specific thing:
4545
4646``` swift
4747
48- public protocol AllPostsUseCase {
48+ public protocol PostsUseCase {
4949 func posts () -> Observable<[Post]>
50- }
51-
52- public protocol SavePostUseCase {
5350 func save (post : Post) -> Observable<Void >
5451}
5552
@@ -84,13 +81,18 @@ final class RMPost: Object {
8481The ` Platform ` also contains concrete implementations of your use cases, repositories or any services that are defined in the ` Domain ` .
8582
8683``` swift
87- final class SavePostUseCase : Domain .SavePostUseCase {
84+ final class PostsUseCase : Domain .PostsUseCase {
85+
8886 private let repository: AbstractRepository<Post>
8987
9088 init (repository : AbstractRepository<Post>) {
9189 self .repository = repository
9290 }
9391
92+ func posts () -> Observable<[Post]> {
93+ return repository.query (sortDescriptors : [Post.CoreDataType .uid .descending ()])
94+ }
95+
9496 func save (post : Post) -> Observable<Void > {
9597 return repository.save (entity : post)
9698 }
@@ -135,12 +137,8 @@ public final class UseCaseProvider: Domain.UseCaseProvider {
135137 postRepository = Repository< Post> (context : coreDataStack.context )
136138 }
137139
138- public func getAllPostsUseCase () -> AllPostsUseCase {
139- return CDAllPostsUseCase (repository : postRepository)
140- }
141-
142- public func getCreatePostUseCase () -> SavePostUseCase {
143- return CDSavePostUseCase (repository : postRepository)
140+ public func makePostsUseCase () -> Domain.PostsUseCase {
141+ return PostsUseCase (repository : postRepository)
144142 }
145143}
146144```
0 commit comments