Permalink
Browse files

removed read / read_result / hold_result

  • Loading branch information...
1 parent 0252a4a commit 2649a5a4dd6b586e25104dc80e0a27de26cc003e Jake Donham committed Apr 30, 2010
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 mouse delay) (fun (x, y) -> (x + mouse_offset, y)) in
+ let tail_pos = F.blift (Fd.delay_b (0, 0) 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 mouse wag_delay) wag_offset
+ (Fd.delay_b (0, 0) mouse wag_delay) wag_offset
(fun (x, y) wag_offset ->
(x + mouseandtail_offset, y + wag_offset)) in
View
8 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 t msb =
- t |> changes |> (fun e -> delay_eb e msb) |> hold_result (read_result t)
+let delay_bb init t msb =
+ t |> changes |> (fun e -> delay_eb e msb) |> hold init
-let delay_b t ms = delay_bb t (return ms)
+let delay_b init t ms = delay_bb init t (return ms)
let mouse_e () =
let e, s = make_event () in
@@ -129,7 +129,6 @@ let appendChild n nb =
| None -> n#appendChild c
| Some oc -> n#replaceChild c oc);
old := Some c in
- update (read_result nb);
notify_result_b nb update
let replaceNode n nb =
@@ -140,7 +139,6 @@ let replaceNode n nb =
let c = node_of_result r in
ignore (p#replaceChild c !old);
old := c in
- update (read_result nb);
notify_result_b nb update
let clicks (elem : #Dom.element) =
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 Froc.behavior -> float -> 'a Froc.behavior
-val delay_bb : 'a Froc.behavior -> float Froc.behavior -> 'a Froc.behavior
+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 mouse_e : unit -> (int * int) Froc.event
val mouse_b : unit -> (int * int) Froc.behavior
View
2 src/froc-dom/froc_dom_anim.ml
@@ -57,6 +57,4 @@ let attach
let notify = function
| Froc.Value instrs -> draw canvas instrs
| Froc.Fail _ -> () (* XXX ? *) in
- (* maybe notify_b should notify when you first call it? *)
- notify (Froc.read_result instrsb);
Froc.notify_result_b instrsb notify
View
8 src/froc/froc.ml
@@ -200,14 +200,12 @@ let switch ?eq b e =
let until ?eq b e = switch ?eq b (next e)
-let hold_result ?eq init e =
- if is_never e then make_constant init else
- let t, u = make_changeable ?eq ~result:init () in
+let hold ?eq init e =
+ if is_never e then return init else
+ let t, u = changeable ?eq 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
23 src/froc/froc.mli
@@ -131,23 +131,6 @@ val try_bind_lift : ?eq:('b -> 'b -> bool) -> (unit -> 'a behavior) -> ('a -> 'b
val join_b : ?eq:('a -> 'a -> bool) -> 'a behavior behavior -> 'a behavior
(** [join_b b] behaves as whichever behavior is currently the value of [b]. *)
-val read : 'a behavior -> 'a
- (**
-
- [read b] returns the current value of [b]; if [b] fails with
- exception [e] it raises [e].
-
- Since [read] doesn't go through the dependency tracking
- machinery, it can get a stale value if called at the wrong
- time. You probably want [bind] instead.
- *)
-
-val read_result : 'a behavior -> 'a result
- (**
- Same as [read] but returns a result instead of possibly raising
- an exception.
- *)
-
val notify_b : ?current:bool -> 'a behavior -> ('a -> unit) -> unit
(**
Adds a listener for the value of a behavior, which is called
@@ -315,12 +298,6 @@ 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
- (**
- [hold_result] is the same as [hold] but initialized with a result
- instead of a value.
- *)
-
val changes : 'a behavior -> 'a event
(** [changes b] fires the value of [b] whenever it changes. *)

0 comments on commit 2649a5a

Please sign in to comment.