Permalink
Browse files

DocumentSaver dispatches a DocumentEvent

  • Loading branch information...
pilu committed Nov 3, 2009
1 parent 8daec84 commit 3000676729aea0bce8760b75f97789710ed50883
@@ -58,7 +58,7 @@ package com.gravityblast.couchdb
private function httpStatusEventHandler(event:Event):void
{
- trace("http status: " + event)
+ // trace("http status: " + event)
}
public function get(uri:String, params:*=null):void
@@ -1,6 +1,5 @@
package com.gravityblast.couchdb
-{
- import com.gravityblast.couchdb.events.CouchRestEvent;
+{
import com.gravityblast.couchdb.events.DocumentEvent;
import flash.utils.describeType;
@@ -52,7 +51,7 @@ package com.gravityblast.couchdb
{
var saver:DocumentSaver = new DocumentSaver(database, this);
if (completeCallback != null)
- saver.addEventListener(CouchRestEvent.COMPLETE, completeCallback);
+ saver.addEventListener(DocumentEvent.SAVED, completeCallback);
saver.save();
}
@@ -33,7 +33,7 @@ package com.gravityblast.couchdb
{
document = event.json;
}
- var e:DocumentEvent = new DocumentEvent(DocumentEvent.LOADED, document);
+ var e:DocumentEvent = new DocumentEvent(DocumentEvent.LOADED, document, event.json, event.data);
this.dispatchEvent(e);
}
}
@@ -1,9 +1,9 @@
package com.gravityblast.couchdb
{
import com.gravityblast.couchdb.events.CouchRestEvent;
+ import com.gravityblast.couchdb.events.DocumentEvent;
import flash.events.EventDispatcher;
- import flash.utils.getQualifiedClassName;
public class DocumentSaver extends EventDispatcher
{
@@ -36,10 +36,9 @@ package com.gravityblast.couchdb
this.document._id = event.json.id;
this.document._rev = event.json.rev;
}
- if (this.hasEventListener(CouchRestEvent.COMPLETE))
- {
- // FIXME:
- var e:CouchRestEvent = new CouchRestEvent(CouchRestEvent.COMPLETE, event.json, event.data);
+ if (this.hasEventListener(DocumentEvent.SAVED))
+ {
+ var e:DocumentEvent = new DocumentEvent(DocumentEvent.SAVED, this.document, event.json, event.data);
this.dispatchEvent(e);
}
}
@@ -6,12 +6,17 @@ package com.gravityblast.couchdb.events
{
public static const LOADED:String = "COUCH_DB_DOCUMENT_LOADED_EVENT";
+ public static const SAVED:String = "COUCH_DB_DOCUMENT_SAVED_EVENT";
public var document:Object;
+ public var json:Object;
+ public var data:String;
- public function DocumentEvent(type:String, document:Object, bubbles:Boolean=false, cancelable:Boolean=false)
+ public function DocumentEvent(type:String, document:Object, json:Object, data:String, bubbles:Boolean=false, cancelable:Boolean=false)
{
this.document = document;
+ this.json = json;
+ this.data = data;
super(type, bubbles, cancelable);
}
}

0 comments on commit 3000676

Please sign in to comment.