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

add function "open_t" #2

Open
wants to merge 14 commits into
base: master
Choose a base branch
from
Open

Conversation

Thibaut-Gudin
Copy link

No description provided.

@Thibaut-Gudin Thibaut-Gudin marked this pull request as draft April 21, 2021 16:10

(*[@@@js.implem*)

open Js_of_ocaml.Dom_html
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Au lieu d'un open ...

val addEventListener :
t -> (*Where to add the listener*)
string -> (*The event type*)
(event -> unit) -> (*The call_back*)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

... essaye Js_of_ocaml.Dom_html.event ici.

Copy link
Author

@Thibaut-Gudin Thibaut-Gudin Apr 22, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

J'avais déjà essayé, le problème restait le même à la seule différence que le message indiquait que "Js_of_ocaml.Dom_html.event_of_js" n'existe pas.
<<
File "cordova_in_app_browser.ml", line 163, characters 47-79:
163 | (Js_of_ocaml.Dom_html.event_of_js
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Unbound value Js_of_ocaml.Dom_html.event_of_js
make: *** [Makefile:17: build] Error 2

val addEventListener :
t -> (*Where to add the listener*)
string -> (*The event type*)
(event -> unit) -> (*The call_back*)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dannywillems Hello Danny !
Would you know whether/how one can use a type like Js_of_ocaml.Dom_html.event in gen_js_api ?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know if I understand correctly the question, but if the function is expecting an event, simply using Js_of_ocaml.Dom_html.event should be enough shouldn't?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unfortunately things are not that simple. Simply using Js_of_ocaml.Dom_html.event will result in gen_js_api generating Js_of_ocaml.Dom_html.event_of_js.

So it seems that one would need to supply a transformation function. I've tried all kinds of stuff already, but to no avail yet.

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using Ojs.t?

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Haven't tried, ugly, and not sure it is the best idea:

type event = Ojs.t

[@@@js.stop]

val of_dom_html : Js_of_ocaml.Dom_html.event -> event

val to_dom_html : event -> Js_of_ocaml.Dom_html.event

[@@@js.start]

[@@@js.implem
let of_dom_html x = Obj.magic x

let to_dom_html x = Obj.magic x]

val addEventListener : t -> string -> (event -> unit) -> unit [@@js.call]

@dannywillems
Copy link
Owner

First, thanks for your contribution! The OCaml ecosystem changed quite a lot since the beginning of this project (dune, ocamlformat, merlin and OPAM are more mature, etc). I'd like to update to the new ecosystem gradually, and add CI (GitHub actions).
I started a branch with the new tools: #3. I haven't got time to check if it is fully retro compatible (building the example app for instance). Would there be one of you keen to try it out pls?

@jrochel
Copy link

jrochel commented May 25, 2021

@Thibaut-Gudin Will do!

@dannywillems
Copy link
Owner

@Thibaut-Gudin Will do!

Thanks! Very helpful!

@Thibaut-Gudin
Copy link
Author

I tried to import "#3" with the BeSport app and it seems that their is no problem with the compilation.

I'm not entirely sure if I made it correctly so I will precise what I done in order to testing with the #3 in local:
First I made a local clone of this branch (https://github.com/dannywillems/ocaml-cordova-plugin-inappbrowser/tree/refacto).
Then I moved in the local clone and I enter those command lines :
-> opam install ocamlformat.0.15.0 merlin
-> opam install -y .
-> opam pin add cordova-plugin-inappbrowser https://github.com/dannywillems/ocaml-cordova-plugin-inappbrowser.git
-> opam reinstall -y cordova-plugin-inappbrowser

Then I tried to compile everything and the compilation seems to succeed.

@jrochel
Copy link

jrochel commented May 26, 2021

-> opam pin add cordova-plugin-inappbrowser dannywillems/ocaml-cordova-plugin-inappbrowser.git

This would make more sense:

opam pin add cordova-plugin-inappbrowser dannywillems/ocaml-cordova-plugin-inappbrowser.git#refacto

@jrochel
Copy link

jrochel commented May 26, 2021

Also: opam install -ydannywillems/ocaml-cordova-plugin-inappbrowser.git . implies opam pin . so you first installed the version you cloned and then dannywillems/ocaml-cordova-plugin-inappbrowser.git which should be identical to the version you cloned.

@Thibaut-Gudin
Copy link
Author

opam pin add cordova-plugin-inappbrowser dannywillems/ocaml-cordova-plugin-inappbrowser.git#refacto

I tried this command line but the cmd return an error:

<<
[NOTE] Package cordova-plugin-inappbrowser is currently pinned to git+https://github.com/dannywillems/ocaml-cordova-plugin-inappbrowser.git (version 1.0).
[ERROR] Could not synchronize /home/thibaut/.opam/4.11.0/.opam-switch/sources/cordova-plugin-inappbrowser from
"git+file:///home/thibaut/forks_Js_Unsafe/pull_Danny_Williams/ocaml-cordova-plugin-inappbrowser/dannywillems/ocaml-cordova-plugin-inappbrowser.git#refacto":
"/usr/bin/git fetch -q" exited with code 128
[ERROR] Error getting source from git+file:///home/thibaut/forks_Js_Unsafe/pull_Danny_Williams/ocaml-cordova-plugin-inappbrowser/dannywillems/ocaml-cordova-plugin-inappbrowser.git#refacto:
- git+file:///home/thibaut/forks_Js_Unsafe/pull_Danny_Williams/ocaml-cordova-plugin-inappbrowser/dannywillems/ocaml-cordova-plugin-inappbrowser.git#refacto

@jrochel
Copy link

jrochel commented May 26, 2021

opam pin add cordova-plugin-inappbrowser [email protected]:dannywillems/ocaml-cordova-plugin-inappbrowser.git#refacto

@Thibaut-Gudin
Copy link
Author

I already test all the function I added on practice, they all seems to works, I tried to add commentary to explain what I added, however I haven't add anything in the "README".

@Thibaut-Gudin Thibaut-Gudin marked this pull request as draft July 2, 2021 09:57
@Thibaut-Gudin
Copy link
Author

Sorry, I realise their maybe something that I had to add later in the library.

@Thibaut-Gudin Thibaut-Gudin marked this pull request as ready for review July 5, 2021 13:05
@Thibaut-Gudin Thibaut-Gudin marked this pull request as draft July 5, 2021 15:00
@Thibaut-Gudin Thibaut-Gudin force-pushed the master branch 2 times, most recently from fe7f37b to 7388b7c Compare July 7, 2021 08:13
@Thibaut-Gudin Thibaut-Gudin marked this pull request as ready for review July 7, 2021 09:29
@dannywillems
Copy link
Owner

Is it ready to be reviewed?

README.md Outdated
@@ -56,3 +56,33 @@ Cordova_in_app_browser.ai_clear_cache true] in
(* Opens in the Cordova WebView if the URL is in the white list *)
i#open_ "https://ocaml.org" (Cordova_in_app_browser.target_self) opt
```

The function "open_t" is hte same as "open" but it return a "typed"
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See this pull-request for the correction and if others corrections are needed for the README:
besport#3

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(@dannywillems No, it's not yet ready to be reviewed yet.)

@jrochel
Copy link

jrochel commented Aug 4, 2021

@dannywillems Alright, I'd say this PR is ready for review.

@jrochel
Copy link

jrochel commented Aug 4, 2021

Actually no, the commits should be squashed first. (@Thibaut-Gudin)

@Thibaut-Gudin
Copy link
Author

Actually no, the commits should be squashed first. (@Thibaut-Gudin)

See besport#4
I don't know if it will do the trick...

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

Successfully merging this pull request may close these issues.

5 participants