add class for js repo of states and start adding of posts list mvvm
This commit is contained in:
client/src/jsMain/kotlin/dev/inmo/postssystem/client
services/posts/client/src
commonMain
kotlin
dev
inmo
postssystem
services
posts
client
jsMain
kotlin
dev
inmo
postssystem
services
posts
client
@ -2,11 +2,10 @@ package dev.inmo.postssystem.services.posts.client
|
||||
|
||||
import dev.inmo.postssystem.features.auth.client.AuthorizedModuleLoader
|
||||
import dev.inmo.postssystem.features.auth.client.AuthorizedQualifiers
|
||||
import dev.inmo.postssystem.features.common.common.DefaultQualifiers
|
||||
import dev.inmo.postssystem.features.common.common.getAllDistinct
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMStateSerializer
|
||||
import dev.inmo.postssystem.services.posts.client.ui.create.*
|
||||
import dev.inmo.postssystem.services.posts.client.ui.posts_list.PostsListUIFSMState
|
||||
import dev.inmo.postssystem.services.posts.common.*
|
||||
import org.koin.core.qualifier.Qualifier
|
||||
import org.koin.dsl.binds
|
||||
|
||||
val loader = AuthorizedModuleLoader {
|
||||
@ -15,6 +14,9 @@ val loader = AuthorizedModuleLoader {
|
||||
WritePostsService::class
|
||||
)
|
||||
|
||||
UIFSMStateSerializer.include("posts_create", PostsCreateUIFSMState.serializer())
|
||||
UIFSMStateSerializer.include("posts_list", PostsListUIFSMState.serializer())
|
||||
|
||||
factory<PostCreateUIModel> { DefaultPostCreateUIModel(get(), get()) }
|
||||
factory { PostCreateUIViewModel(get()) }
|
||||
}
|
||||
|
10
services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ui/create/PostsCreateUIFSMState.kt
Normal file
10
services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ui/create/PostsCreateUIFSMState.kt
Normal file
@ -0,0 +1,10 @@
|
||||
package dev.inmo.postssystem.services.posts.client.ui.create
|
||||
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMState
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PostsCreateUIFSMState(
|
||||
override val from: UIFSMState? = null,
|
||||
override val context: String = "main"
|
||||
) : UIFSMState
|
10
services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ui/posts_list/PostsListUIFSMState.kt
Normal file
10
services/posts/client/src/commonMain/kotlin/dev/inmo/postssystem/services/posts/client/ui/posts_list/PostsListUIFSMState.kt
Normal file
@ -0,0 +1,10 @@
|
||||
package dev.inmo.postssystem.services.posts.client.ui.posts_list
|
||||
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.UIFSMState
|
||||
import kotlinx.serialization.Serializable
|
||||
|
||||
@Serializable
|
||||
data class PostsListUIFSMState(
|
||||
override val from: UIFSMState? = null,
|
||||
override val context: String = "main"
|
||||
) : UIFSMState
|
12
services/posts/client/src/jsMain/kotlin/dev/inmo/postssystem/services/posts/client/PostCreateView.kt
12
services/posts/client/src/jsMain/kotlin/dev/inmo/postssystem/services/posts/client/PostCreateView.kt
@ -13,10 +13,10 @@ import dev.inmo.postssystem.features.common.common.ui.JSView
|
||||
import dev.inmo.postssystem.features.common.common.ui.fsm.*
|
||||
import dev.inmo.postssystem.features.content.client.ContentClientProvider
|
||||
import dev.inmo.postssystem.features.content.common.Content
|
||||
import dev.inmo.postssystem.services.posts.client.ui.create.PostsCreateUIFSMState
|
||||
import dev.inmo.postssystem.services.posts.client.ui.create.PostCreateUIViewModel
|
||||
import kotlinx.coroutines.CompletableDeferred
|
||||
import kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.serialization.Serializable
|
||||
import org.jetbrains.compose.web.dom.Div
|
||||
import org.jetbrains.compose.web.dom.Text
|
||||
import org.w3c.dom.HTMLElement
|
||||
@ -31,21 +31,15 @@ val jsLoader = DefaultModuleLoader {
|
||||
}
|
||||
}
|
||||
|
||||
@Serializable
|
||||
data class CreatePostUIFSMState(
|
||||
override val from: UIFSMState? = null,
|
||||
override val context: String = "main"
|
||||
) : UIFSMState
|
||||
|
||||
class PostCreateView(
|
||||
private val createPostCreateUIModel: PostCreateUIViewModel,
|
||||
private val contentClientProviders: List<ContentClientProvider>,
|
||||
private val uiScope: CoroutineScope,
|
||||
defaultExceptionsHandlers: Iterable<UIFSMExceptionHandler>
|
||||
) : JSView<CreatePostUIFSMState>(defaultExceptionsHandlers) {
|
||||
) : JSView<PostsCreateUIFSMState>(defaultExceptionsHandlers) {
|
||||
override suspend fun StatesMachine<in UIFSMState>.safeHandleState(
|
||||
htmlElement: HTMLElement,
|
||||
state: CreatePostUIFSMState
|
||||
state: PostsCreateUIFSMState
|
||||
): UIFSMState? {
|
||||
val result = CompletableDeferred<UIFSMState?>()
|
||||
|
||||
|
Reference in New Issue
Block a user