oleg-py / shironeko

Frontend state management library for cats-effect
27 stars 3 forks source link

scalajs 1.x support #3

Closed mprevel closed 4 years ago

mprevel commented 4 years ago

WIP to support scalajs 0.6.x and 1.x

Requires cats-effect 2.1.4 to be published in order get a fix on IOApp for the browser demo : https://github.com/typelevel/cats-effect/commit/78dd1cf954728e2389bd6d2b630934aadf8383e3 So the dependency override (master hash at the moment) could be removed.

Demo crash requires further investigation :

Uncaught TypeError: Cannot read property 'Lcom_olegpy_shironeko_TaglessConnector$RenderInstance__f_algebra' of null
    at $f_Lcom_olegpy_shironeko_TaglessConnector$RenderHelpers__getAlgebra__Lcom_olegpy_shironeko_TaglessConnector$SubscribeM__O (Predef.scala:221)
    at $c_Lcom_olegpy_shironeko_todomvc_TodoApp$.subscribe__Lfs2_internal_FreeC (DirectConnector.scala:47)
    at $c_Lcom_olegpy_shironeko_DirectConnector$Container$Impl$.subscribe__Lcom_olegpy_shironeko_TaglessConnector$SubscribeM__Lfs2_internal_FreeC (DirectConnector.scala:35)
    at $c_Lcom_olegpy_shironeko_TaglessConnector$Container$underlying$.subscribe__Lcom_olegpy_shironeko_TaglessConnector$SubscribeM__Lfs2_internal_FreeC (TaglessConnector.scala:133)
    at eval (TaglessConnector.scala:96)
    at $c_sjsr_AnonFunction0.apply__O (AnonFunctions.scala:22)
    at eval (React.scala:271)
    at commitHookEffectList (react-dom.development.js:17283)
    at commitLifeCycles (react-dom.development.js:17316)
    at commitAllLifeCycles (react-dom.development.js:18736)
oleg-py commented 4 years ago

Demo crash is definitely issue on my side there - I haven't yet found a nice way for internals of DirectConnector to work. I've added a temporary version to master for now, and also I've pushed a workaround for cats-effect issue in JS code of todoMVC, so that shironeko build doesn't need local publishing or snapshots.

mprevel commented 4 years ago

Thanks. I'll check that tonight. :) I've already started using the the 2.13 version with scala.js 1.1.0 in a project with slinky. This is not yet battle-tested but seems to work well :) I've seen that SlinkyConnector from the docs seems to have been removed, so I used TaglessConnector.

mprevel commented 4 years ago

Hi Oleg,

Sorry for being late on this PR but I was quite busy lately. I tried to update to the last commit to finalize this PR but I get an issue on master branch on DirectConnector.

[error] shironeko/slinky/src/main/scala/com/olegpy/shironeko/DirectConnector.scala:19:47: type mismatch;
[error]  found   : cats.effect.ConcurrentEffect[F]
[error]  required: cats.effect.ConcurrentEffect[F[a]]
[error]     ef = new Underlying.RenderInstance(store, F)

Did I miss something ?

oleg-py commented 4 years ago

Looks like I missed an issue with 2.12 type inference there. Generally, feel free to just push what you have and ask if you get an error you're not sure how to resolve :)

mprevel commented 4 years ago

Hi Oleg,

I updated the PR.

I am able to publish locally and to run the TODOS demo. :) SCALAJS_VERSION=0.6.33 sbt +publishLocal SCALAJS_VERSION=1.1.0 sbt +publishLocal

oleg-py commented 4 years ago

I'll check it and hopefully publish a version to maven soon. Thanks for contributing!