Legend:
Page
Library
Module
Module type
Parameter
Class
Class type
Source
Source file start.ml
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157open!Core_kernelopen!Async_kernelopen!ImportmoduleHandle=structmoduleInjector=structtype'at=|Before_app_startof'aQueue.t|Injectof('a->Vdom.Event.t)endtype('input,'incoming,'outgoing)t={mutableinjector:'incomingInjector.t;stop:unitIvar.t;started:unitIvar.t;input_var:'inputIncr.Var.t;outgoing_pipe:'outgoingPipe.Reader.t}letcreate~input_var~outgoing_pipe={injector=Before_app_start(Queue.create());stop=Ivar.create();started=Ivar.create();input_var;outgoing_pipe};;letstopt=Ivar.fill_if_emptyt.stop()letstartedt=Ivar.readt.startedletscheduleta=matcht.injectorwith|Injectf->fa|>Vdom.Event.Expert.handle_non_dom_event_exn|Before_app_startqueue->Queue.enqueuequeuea;;letset_injecttinject=letprev=t.injectorint.injector<-Injectinject;matchprevwith|Inject_->()|Before_app_startqueue->Queue.iterqueue~f:(schedulet);;letset_inputtinput=Incr.Var.sett.input_varinputletoutgoing{outgoing_pipe;_}=outgoing_pipeendletstart_generic_poly(typeinputinput_and_injectmodelactionresultincomingoutgoing)~(get_dom_and_inject:result->Vdom.Node.t*(incoming->Vdom.Event.t))~(get_input_and_inject:input->(outgoing->Vdom.Event.t)->input_and_inject)~(initial_input:input)~(initial_model:model)~bind_to_element_with_id~(component:(input_and_inject,model,action,result)Bonsai.Expert.unpacked)~(action_type_id:actionType_equal.Id.t):(input,incoming,outgoing)Handle.t=letoutgoing_pipe,pipe_write=Pipe.create()inletmoduleOut_event=Virtual_dom.Vdom.Event.Define(structmoduleAction=structtypet=outgoingendlethandle=Pipe.write_without_pushback_if_openpipe_writeend)inletinput_var=Incr.Var.createinitial_inputinlethandle=Handle.create~input_var~outgoing_pipeinletmoduleIncr_dom_app=structmoduleModel=structtypet=modelletcutoff=phys_equalendmoduleState=structtypet=unitendmoduleAction=structtypet=actionletsexp_of_t=Type_equal.Id.to_sexpaction_type_idendleton_startup~schedule_action:__=return()letcreatemodel~old_model~inject=letopenIncr.Let_syntaxinletold_model=old_model>>|Option.someinletinput=let%mapinput=Incr.Var.watchinput_varinget_input_and_injectinputOut_event.injectinlet%mapsnapshot=Bonsai.Expert.eval~input~old_model~model~injectcomponent~action_type_idandmodel=modelinletapply_action=Bonsai.Expert.Snapshot.apply_actionsnapshotinletapply_actionaction()~schedule_action:_=apply_action~schedule_event:Vdom.Event.Expert.handle_non_dom_event_exnactioninletresult=Bonsai.Expert.Snapshot.resultsnapshotinletdom,inject=get_dom_and_injectresultinHandle.set_injecthandleinject;Incr_dom.Component.create~apply_actionmodeldom;;endinIncr_dom.Start_app.start~bind_to_element_with_id~initial_model~stop:(Ivar.readhandle.stop)(moduleIncr_dom_app);handle;;letstart_generic~get_dom_and_inject~initial_input~initial_model~bind_to_element_with_id~component=let(T(unpacked,action_type_id))=Bonsai.Expert.revealcomponentinstart_generic_poly~get_dom_and_inject~initial_input~initial_model~bind_to_element_with_id~component:unpacked~action_type_id;;(* I can't use currying here because of the value restriction. *)letstart_standalone~initial_input~initial_model~bind_to_element_with_idcomponent=start_generic~get_dom_and_inject:(funresult->result,Nothing.unreachable_code)~get_input_and_inject:(funinput_inject->input)~initial_input~initial_model~bind_to_element_with_id~component;;letstart~initial_input~initial_model~bind_to_element_with_idcomponent=start_generic~get_dom_and_inject:Fn.id~get_input_and_inject:Tuple2.create~initial_input~initial_model~bind_to_element_with_id~component;;