12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788# 1 "src/lib/eliom_react.client.ml"(* Ocsigen
* http://www.ocsigen.org
* Copyright (C) 2010-2011
* Raphaël Proust
* Pierre Chambart
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published by
* the Free Software Foundation, with linking exception;
* either version 2.1 of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*)(* Module for event unwrapping *)let(>|=)=Lwt.(>|=)openLwt_reactletsection=Lwt_log_js.Section.make"eliom:comet"moduleDown=structtype'at='aReact.E.tlethandle_react_exn,set_handle_react_exn_function=letr=ref(fun?exn()->lets="Exception during comet with react. Customize this with Eliom_react.set_handle_react_exn_function. "inLwt_log_js.log~section~level:Lwt_log_js.Debug?exns)in(fun?exn()->!r?exn()),funf->r:=fletinternal_unwrap(channel,_unwrapper)=(* We want to catch more exceptions here than the usual exceptions caught
in Eliom_comet. For example Channel_full. *)(* We transform the stream into a stream with exception: *)letstream=Lwt_stream.wrap_exnchannelinLwt.async(fun()->Lwt_stream.iter_s(function|Errorexn->let%lwt()=handle_react_exn~exn()inLwt.failexn|Ok()->Lwt.return_unit)stream);E.of_streamchannellet()=Eliom_unwrap.register_unwrapperEliom_common.react_down_unwrap_idinternal_unwrapendmoduleUp=structtype'at='a->unitLwt.tletinternal_unwrap(service,_unwrapper)x=Eliom_client.call_service~service()x>|=fun_->()let()=Eliom_unwrap.register_unwrapperEliom_common.react_up_unwrap_idinternal_unwrapendmoduleS=structmoduleDown=structtype'at='aReact.S.tletinternal_unwrap(channel,value,_unwrapper)=lete=E.of_streamchannelinS.hold~eq:(fun__->false)valueelet()=Eliom_unwrap.register_unwrapperEliom_common.signal_down_unwrap_idinternal_unwrapendendletforce_link=()