badoo / MVIKotlin

Extendable MVI framework for Kotlin Multiplatform with powerful debugging tools (logging and time travel), inspired by Badoo MVICore library
https://arkivanov.github.io/MVIKotlin
Apache License 2.0
827 stars 64 forks source link

Issue with mvikotlin-extensions-coroutines based store implementation on JS target #145

Closed denislfernandez closed 4 years ago

denislfernandez commented 4 years ago

Hi,

I'm encountering the following error when trying to use the store and related coroutine based implementations of the mvikotlin-extensions-coroutines package on a JS browser target.

ReferenceError: observer$ObjectLiteral is not defined

Both with my project and with the sample Todo project the issue is met. The easiest way to reproduce the error is executing the browserDevelopmentRun task after changing the FrameworkType from REAKTIVE to COROUTINES on the todo-app-js module

val mFrameworkType: FrameworkType = FrameworkType.COROUTINES inside todo-app-js/src/main/kotlin/Util.kt

This is the console log of the web browser for the error

ReferenceError: observer$ObjectLiteral is not defined doResume Utils.kt:16 lambda_0 Utils.kt:15 collectTo_sz7tnc$ kotlinx-coroutines-core.js:19406 doResume kotlinx-coroutines-core.js:19440 collectTo_sz7tnc$ kotlinx-coroutines-core.js:19470 doResume kotlinx-coroutines-core.js:21186 resumeWith_tl1gpc$ CoroutineImpl.kt:47 run kotlinx-coroutines-core.js:34305 process kotlinx-coroutines-core.js:37640 lambda kotlinx-coroutines-core.js:37595 promise callback*WindowMessageQueue.prototype.schedule kotlinx-coroutines-core.js:37600 enqueue_771g0p$ kotlinx-coroutines-core.js:37627 dispatch_5bn72i$ kotlinx-coroutines-core.js:37551 dispatch_5bn72i$ kotlinx-coroutines-core.js:37335 resumeCancellableWith kotlinx-coroutines-core.js:34143 startCoroutineCancellable_0 kotlinx-coroutines-core.js:35142 invoke_3o0yor$ kotlinx-coroutines-core.js:2186 start_b5ul0p$ kotlinx-coroutines-core.js:446 launch kotlinx-coroutines-core.js:829 handleAction SuspendExecutor.kt:52 handleAction LoggingExecutor.kt:34 process_fpuznb$ TimeTravelStoreImpl.kt:146 process_fpuznb$ TimeTravelStoreImpl.kt:113 process_0 TimeTravelControllerImpl.kt:239 onEvent_0 TimeTravelControllerImpl.kt:170 observerThreadLocalHolder MVIKotlin-mvikotlin-timetravel.js:138 onNext ObserverBuilder.kt:9 lambda_1 TimeTravelControllerImpl.kt:56 onNext ObserverBuilder.kt:9 drain_0 ThreadLocalSubject.kt:66 drainIfNeeded_0 ThreadLocalSubject.kt:56 onNext ThreadLocalSubject.kt:43 onEvent_0 TimeTravelStoreImpl.kt:124 lambda TimeTravelStoreImpl.kt:98 action MVIKotlin-mvikotlin.js:755 invoke _Arrays.kt:13416 init TimeTravelStoreImpl.kt:101 attachStore_x1ts8j$ TimeTravelControllerImpl.kt:61 attachTimeTravelStore TimeTravelControllerProvider.kt:21 create$default Standard.kt:98 create StoreFactory.kt:12 create$default LoggingStoreFactory.kt:65 create StoreFactory.kt:12 TodoListStoreAbstractFactory$create$ObjectLiteral TodoListStoreAbstractFactory.kt:24 create TodoListStoreAbstractFactory.kt:24 lambda TodoListCoroutinesController.kt:49 getOrCreateStore InstanceKeeperExt.kt:35 TodoListCoroutinesController TodoListCoroutinesController.kt:43 createController_0 TodoListComponent.kt:68 componentDidMount TodoListComponent.kt:51 React 6 unstable_runWithPriority scheduler.development.js:653 React 10 render_0 ReactDOM.kt:7 Application$start$lambda Main.kt:17 start Main.kt:16 main Main.kt:30

MVIKotlin-todo-app-js.js:1756 MVIKotlin-todo-app-js.js:1759 js todo-app-js.js:6355 __webpack_require__ todo-app-js.js:30 0 todo-app-js.js:6543 __webpack_require__ todo-app-js.js:30 todo-app-js.js:94 todo-app-js.js:97 webpackUniversalModuleDefinition todo-app-js.js:9 todo-app-js.js:10 kotlinx-coroutines-core.js:37289 ReferenceError: observer$ObjectLiteral is not defined doResume Utils.kt:16 lambda Utils.kt:15 collectTo_sz7tnc$ kotlinx-coroutines-core.js:19406 doResume kotlinx-coroutines-core.js:19440 collectTo_sz7tnc$ kotlinx-coroutines-core.js:19470 doResume kotlinx-coroutines-core.js:21186 resumeWith_tl1gpc$ CoroutineImpl.kt:47 run kotlinx-coroutines-core.js:34305 process kotlinx-coroutines-core.js:37640 lambda kotlinx-coroutines-core.js:37609 WindowMessageQueue kotlinx-coroutines-core.js:37591 WindowDispatcher kotlinx-coroutines-core.js:37548 asCoroutineDispatcher kotlinx-coroutines-core.js:37810 createDefaultDispatcher kotlinx-coroutines-core.js:37251 Dispatchers kotlinx-coroutines-core.js:37310 Dispatchers_getInstance kotlinx-coroutines-core.js:37321 MVIKotlin-todo-coroutines.js:2278 MVIKotlin-todo-coroutines.js:5 MVIKotlin-todo-coroutines.js:8 js todo-app-js.js:6388 __webpack_require__ todo-app-js.js:30 MVIKotlin-todo-app-js.js:1759 js todo-app-js.js:6355 __webpack_require__ todo-app-js.js:30 0 todo-app-js.js:6543 __webpack_require__ todo-app-js.js:30 todo-app-js.js:94 todo-app-js.js:97 webpackUniversalModuleDefinition todo-app-js.js:9 todo-app-js.js:10

Both with the sample todo-app-js module and with a store implementation based on mvikotlin-extensions-reaktive for my project no error is thrown and web app seems to work just fine

arkivanov commented 4 years ago

Thanks for reporting the issue, I will check