Skip to content

Commit

Permalink
fix JS unsupported api
Browse files Browse the repository at this point in the history
  • Loading branch information
dsvag committed Apr 29, 2024
1 parent 3a99b51 commit 8e4e122
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import kotlinx.coroutines.isActive
import kotlinx.coroutines.launch
import money.vivid.elmslie.core.ElmScope
import money.vivid.elmslie.core.config.ElmslieConfig
import money.vivid.elmslie.core.utils.resolveStoreKey

@Suppress("TooGenericExceptionCaught")
@OptIn(ExperimentalCoroutinesApi::class)
Expand All @@ -26,11 +27,7 @@ class ElmStore<Event : Any, State : Any, Effect : Any, Command : Any>(
private val actor: Actor<Command, out Event>,
storeListeners: Set<StoreListener<Event, State, Effect, Command>>? = null,
override val startEvent: Event? = null,
private val key: String =
(reducer::class.qualifiedName ?: reducer::class.simpleName).orEmpty().replace(
"Reducer",
"Store",
),
private val key: String = resolveStoreKey(reducer),
) : Store<Event, Effect, State> {

private val logger = ElmslieConfig.logger
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package money.vivid.elmslie.core.utils

import money.vivid.elmslie.core.store.StateReducer

internal expect fun resolveStoreKey(reducer: StateReducer<*, *, *, *>): String
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package money.vivid.elmslie.core.utils

import money.vivid.elmslie.core.store.StateReducer

internal actual fun resolveStoreKey(reducer: StateReducer<*, *, *, *>): String =
(reducer::class.qualifiedName ?: reducer::class.simpleName)
.orEmpty()
.replace("Reducer", "Store")
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package money.vivid.elmslie.core.utils

import money.vivid.elmslie.core.store.StateReducer

internal actual fun resolveStoreKey(reducer: StateReducer<*, *, *, *>): String =
(reducer::class.qualifiedName ?: reducer::class.simpleName)
.orEmpty()
.replace("Reducer", "Store")
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package money.vivid.elmslie.core.utils

import money.vivid.elmslie.core.store.StateReducer

internal actual fun resolveStoreKey(reducer: StateReducer<*, *, *, *>): String =
reducer::class.simpleName
.orEmpty()
.replace("Reducer", "Store")

0 comments on commit 8e4e122

Please sign in to comment.