Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

oops meant to revert these read{,_result} changes (now sample{,_result})

  • Loading branch information...
commit 9695ac16e26c7fb0ee2085c2a2b97062d5d117f0 1 parent 306dad9
Jake Donham authored
View
4 examples/froc-dom/follow-the-mouse/follow.ml
@@ -40,7 +40,7 @@ let onload () =
[ D.document#createTextNode "the mouse!" ]));
let mouse_offset = (D.document#getElementById "themouse")#_get_offsetWidth in
- let tail_pos = F.blift (Fd.delay_b (0, 0) mouse delay) (fun (x, y) -> (x + mouse_offset, y)) in
+ let tail_pos = F.blift (Fd.delay_b mouse delay) (fun (x, y) -> (x + mouse_offset, y)) in
Fd.appendChild body
(F.blift tail_pos (fun (x, y) ->
@@ -59,7 +59,7 @@ let onload () =
let wag_offset = F.hold 0 (F.collect (fun _ _ -> (Random.int 10) - 5) 0 (Fd.ticks 100.)) in
let wag_pos =
F.blift2
- (Fd.delay_b (0, 0) mouse wag_delay) wag_offset
+ (Fd.delay_b mouse wag_delay) wag_offset
(fun (x, y) wag_offset ->
(x + mouseandtail_offset, y + wag_offset)) in
View
6 src/froc-dom/froc_dom.ml
@@ -76,10 +76,10 @@ let delay_eb t msb =
let delay_e t ms = delay_eb t (return ms)
-let delay_bb init t msb =
- t |> changes |> (fun e -> delay_eb e msb) |> hold init
+let delay_bb t msb =
+ t |> changes |> (fun e -> delay_eb e msb) |> hold_result (sample_result t)
-let delay_b init t ms = delay_bb init t (return ms)
+let delay_b t ms = delay_bb t (return ms)
let mouse_e () =
let e, s = make_event () in
View
4 src/froc-dom/froc_dom.mli
@@ -23,8 +23,8 @@ val ticks_b : float Froc.behavior -> unit Froc.event
val delay_e : 'a Froc.event -> float -> 'a Froc.event
val delay_eb : 'a Froc.event -> float Froc.behavior -> 'a Froc.event
-val delay_b : 'a -> 'a Froc.behavior -> float -> 'a Froc.behavior
-val delay_bb : 'a -> 'a Froc.behavior -> float Froc.behavior -> 'a Froc.behavior
+val delay_b : 'a Froc.behavior -> float -> 'a Froc.behavior
+val delay_bb : 'a Froc.behavior -> float Froc.behavior -> 'a Froc.behavior
val mouse_e : unit -> (int * int) Froc.event
val mouse_b : unit -> (int * int) Froc.behavior
View
8 src/froc/froc.ml
@@ -202,12 +202,14 @@ let switch ?eq b e =
let until ?eq b e = switch ?eq b (next e)
-let hold ?eq init e =
- if is_never e then return init else
- let t, u = changeable ?eq init in
+let hold_result ?eq init e =
+ if is_never e then make_constant init else
+ let t, u = make_changeable ?eq ~result:init () in
notify_result_e e (write_result u);
t
+let hold ?eq init e = hold_result ?eq (Value init) e
+
let changes b =
if is_constant b then never else
let t, u = make_event () in
View
5 src/froc/froc.mli
@@ -309,6 +309,11 @@ val hold : ?eq:('a -> 'a -> bool) -> 'a -> 'a event -> 'a behavior
gives the equality on the resulting behavior.
*)
+val hold_result : ?eq:('a -> 'a -> bool) -> 'a result -> 'a event -> 'a behavior
+ (**
+ Same as [hold] but initialized with a result.
+ *)
+
val changes : 'a behavior -> 'a event
(** [changes b] fires the value of [b] whenever it changes. *)

0 comments on commit 9695ac1

Please sign in to comment.
Something went wrong with that request. Please try again.