Permalink
Browse files

Fix signal being fired before object exists

  • Loading branch information...
1 parent bad42fe commit 329f0473ac234bbcd116a117259d9c1cafb2b85e @VictorNicollet committed Apr 11, 2013
Showing with 8 additions and 5 deletions.
  1. +8 −5 ohmCouchVersioned/ohmCouchVersioned.ml
@@ -284,12 +284,15 @@ module Make = functor (Versioned:VERSIONED) -> struct
method diffs = diffs
end in
- let! () = ohm begin
- let! () = ohm $ Run.edit_context Versioned.couchDB (VersionTable.set vid version) in
- Signals.version_create_call (vid,version)
- end in
+ let! () = ohm (Run.edit_context Versioned.couchDB (VersionTable.set vid version)) in
+
+ let! result = ohm_req_or (return None) (refresh ~latest:(vid,version) id default) in
+
+ (* The refresh might create the object, so wait until after the refresh to call
+ any relevant signals. *)
+ let! () = ohm (Signals.version_create_call (vid,version)) in
- refresh ~latest:(vid,version) id default
+ return (Some result)
let update ~id ~diffs ~info () =
do_update ~id ~default:None ~diffs ~info ()

0 comments on commit 329f047

Please sign in to comment.