Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to use jsaddle-clib #90

Open
nomeata opened this issue May 11, 2019 · 8 comments
Open

How to use jsaddle-clib #90

nomeata opened this issue May 11, 2019 · 8 comments

Comments

@nomeata
Copy link

nomeata commented May 11, 2019

The documentation lists jsaddle-clib as one of the runners to choose from. All the other runners seem to export a more or less compatible run function, but not jsaddle-clib. Some documentation on how to use jsaddle-clib would be helpful.

@nomeata
Copy link
Author

nomeata commented May 11, 2019

Also I am confused about the relation between the android-activity package and jsaddle-clib. Do they complement each other, or do they have overlapping functionality?

@nomeata
Copy link
Author

nomeata commented May 11, 2019

The only actual use of import Language.Javascript.JSaddle.CLib that I found using GitHub is https://github.com/obsidiansystems/cross-android/blob/develop/hs/src/Main.hs but that seems to be outdated?

@nomeata
Copy link
Author

nomeata commented May 11, 2019

Hmm, it seems that if one wants to use reflex, then reflex-dom has its own support for creating an Android Activity, that somehow revolves around https://github.com/reflex-frp/reflex-dom/blob/develop/reflex-dom/src-android/Reflex/Dom/Android/MainWidget.hsc and https://github.com/reflex-frp/reflex-dom/blob/1eb43e17c98c1fc67eb21000e2057e3b8488e446/reflex-dom/cbits/MainWidget.c and https://github.com/reflex-frp/reflex-dom/blob/1eb43e17c98c1fc67eb21000e2057e3b8488e446/reflex-dom/java/org/reflexfrp/reflexdom/MainWidget.java and hence does not use the more general purpose android-activity package.

Or does it complement it? https://github.com/gonimo/gonimo/blob/master/front-android/app/Android.hs seems to be using both.

But I can’t find any indication on how to run my non-reflex jsaddle app properly on android (let alone my sdl application … but that’s off topic for here.)

@eskimor, are you watching this space? You seem to be the expert here :-)

@nomeata
Copy link
Author

nomeata commented May 11, 2019

More sleuthing; it seems that https://github.com/reflex-frp/reflex-dom/blob/master/reflex-dom/src-android/Reflex/Dom/Android/MainWidget.hsc isn’t actually tied to reflex. Maybe this could and should be its own package, but isn’t because nobody asked for it? There is a comment

 --TODO: Find a way to eventually release this

@nomeata
Copy link
Author

nomeata commented May 11, 2019

Ugh:

src/KaleidogenAndroid.hs:12:1: error:
    Could not find module ‘Reflex.Dom.Android.MainWidget’
    it is a hidden module in the package ‘reflex-dom-0.5’
    Use -v to see a list of the files searched for.
   |
12 | import           Reflex.Dom.Android.MainWidget
   | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

so how did gonimo do it? Maybe an older version did export that module?

@nomeata
Copy link
Author

nomeata commented May 11, 2019

Despite not using reflex, this seems to line up in terms of types, and is the most promising variant so far:

module KaleidogenAndroid where

import MainWidget
import Reflex.Dom.Internal

main :: IO ()
main = run MainWidget.mainWidget

(where mainWidget :: JSM ()).

If that works out I guess I’ll have to bug the reflex people to provide that functionality in a separate library… :-)

@nomeata
Copy link
Author

nomeata commented May 11, 2019

Well, (after renaming that to Main) it built and created an android app (using nix and buildApp from reflex-platform), and I can start and run it. That’s progress :-)

(I’d still be interested in the original question: how to use jaddle-clib directly)

@eskimor
Copy link

eskimor commented May 13, 2019

Sorry - I am late on this, but glad you got it to work! I can't really say anything about direct usage of jsaddle-clib unfortunately. Except maybe that I think it is unlikely that it will suffice for running your Application on Android, as this also requires some integration with the Java SDK. You would need to wire it up manually with the Android WebView too.

Regarding on how Gonimo did it: I was quite liberal with patching dependencies with features I needed. In particular: https://github.com/eskimor/reflex-dom/blob/5dd733e25fd16ff628560a9bc6583b170f13dacb/reflex-dom/reflex-dom.cabal#L92-L94

Most stuff I needed however, that I did not consider too application specific got merged to master at some point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants