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

An error occurred while executing make client, because the function of _requestAnimationFrame is deprecated. #34

Open
coldlapy opened this issue Jun 25, 2024 · 1 comment

Comments

@coldlapy
Copy link

An error occurred while executing make client

dune build ./js/client.bc.js @runtest
File "js/ck_animate.ml", line 40, characters 8-39:
Error (warning 3): deprecated: Js_of_ocaml.Dom_html._requestAnimationFrame
[since 2.6] Use [Dom_html.window##requestAnimationFrame] instead.
File "js/ck_animate.ml", line 74, characters 8-39:
Error (warning 3): deprecated: Js_of_ocaml.Dom_html._requestAnimationFrame
[since 2.6] Use [Dom_html.window##requestAnimationFrame] instead.
File "js/ck_animate.ml", line 97, characters 22-53:
Error (warning 3): deprecated: Js_of_ocaml.Dom_html._requestAnimationFrame
[since 2.6] Use [Dom_html.window##requestAnimationFrame] instead.
make: *** [Makefile:14: client-test] Error 1

I checked the Dom_html description of Js_of_ocaml,

Deprecated [since 2.6] Use [Dom_html.window##requestAnimationFrame] instead.

So I modified it like this

[Dom_html.window##requestAnimationFrame] (Js.wrap_callback aux)

But it still reports an error

File "js/ck_animate.ml", line 40, characters 9-47:
Error: This expression has type
         (float -> unit) Js_of_ocaml__.Js.callback ->
         Dom_html.animation_frame_request_id Js.meth
       but an expression was expected of type 'a Js.meth
make: *** [Makefile:14: client-test] Error 1

Deprecated function.

val _requestAnimationFrame : (unit -> unit) [Js.callback]

It seems that there is a type mismatch. After learning some ocaml, I found that it is not so easy to modify, so I had to come here to ask for advice. thanks!

@talex5
Copy link
Owner

talex5 commented Jun 29, 2024

Looking at https://developer.mozilla.org/en-US/docs/Web/API/Window/requestAnimationFrame it seems that:

  • aux now gets a timestamp (float)
  • requestAnimationFrame now returns an ID

You probably want something like let rec aux ts = ... and ignore (Dom_html.window##requestAnimationFrame (Js.wrap_callback aux) : Dom_html.animation_frame_request_id).

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