eliom icon indicating copy to clipboard operation
eliom copied to clipboard

Assert_failure src/lib/eliom_uri.shared.ml:578:13

Open slegrand45 opened this issue 9 years ago • 1 comments

Hi,

With the code below, when i click on the "delete" button, i get the message "Assert_failure src/lib/eliom_uri.shared.ml:578:13" on the javascript console. Tested with eliom 5.

open Lwt.Infix

[%%shared
    type record = {
      id : Int64.t ;
      name : string ;
    }
]

let delete_record_service =
  Eliom_registration.Ocaml.register_delete_coservice'
    ~get_params:(Eliom_parameter.int64 "id")
    (fun id _ -> Lwt.return Int64.zero)

let list_records :
  (record Eliom_shared.ReactiveData.RList.t * record Eliom_shared.ReactiveData.RList.handle) =
  Eliom_shared.ReactiveData.RList.create [{ id = Int64.zero; name = "Name" }]

[%%client
let update id =
  let%lwt nb =
    Eliom_client.call_ocaml_service ~service:~%delete_record_service id (None, None)
  in
  Lwt.return_unit
]

let node_list () =
  let (s, _) = list_records in
  let html =
    Eliom_shared.ReactiveData.RList.map
      [%shared
        fun v ->            
          let d_button id = Eliom_content.Html5.(
            let bt = D.button [D.pcdata "delete"] in
            let _ = [%client
              (Lwt.async (fun () ->
                 let bt = Eliom_content.Html5.To_dom.of_button ~%bt in
                 Lwt_js_events.clicks bt (fun _ _ ->
                   let _ = update ~%id in
                   Lwt.return ()
                 ))
               : unit)]
            in
            bt
          ) in
          Eliom_content.Html5.(
            D.li [D.pcdata (Printf.sprintf "%Li" v.id) ;
                  D.pcdata (Printf.sprintf "%s" v.name) ;
                  d_button v.id ;
                 ]
          )
      ] s
  in
  Eliom_content.Html5.R.ul html

let view () =
  let html = 
    Eliom_content.Html5.(
      F.body [ node_list () ]
    )
  in
  html

module Test_app =
  Eliom_registration.App (
  struct
    let application_name = "test"
  end)

let main_service =
  Eliom_service.App.service
    ~path:[]
    ~get_params:Eliom_parameter.unit ()

let () =
  Test_app.register ~service:main_service @@ fun () () ->
  Lwt.return @@ Eliom_tools.F.html
    ~title:"test"
    (view ())

slegrand45 avatar Apr 11 '16 08:04 slegrand45