Skip to content

Commit

Permalink
Making sure PushEndEvents are dispatched even if there's no data to
Browse files Browse the repository at this point in the history
push. Add version identifier to the code so you can determine at runtime
wcich Rx framework version you are using.
  • Loading branch information
dima committed Jan 15, 2011
1 parent e57ff60 commit 41bc80d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions framework/src/org/restfulx/Rx.as
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,11 @@ package org.restfulx {
*/
public class Rx {

/**
* Indiciates current frarmework version
*/
public static const version:String = "1.3.1";

/**
* Framework logger. In order to see any framework-level logging at all
* you should call <code>Rx.enableLogging()</code> anywhere in your
Expand Down
10 changes: 9 additions & 1 deletion framework/src/org/restfulx/controllers/ChangeController.as
Original file line number Diff line number Diff line change
Expand Up @@ -162,10 +162,10 @@ package org.restfulx.controllers {
notifiedPushStart = true;
dispatchEvent(new PushStartEvent);
for each (var model:Class in models) {
pushModels.push(Rx.models.state.types[model]);
source.dirty(model, new ItemResponder(onDirtyChanges, onDirtyFault));
}
}

}

/**
Expand Down Expand Up @@ -272,6 +272,10 @@ package org.restfulx.controllers {
protected function onDirtyChanges(result:Object, token:Object = null):void {
var data:TypedArray = result as TypedArray;

pushModels = pushModels.filter(function(item:*, index:int, a:Array):Boolean {
return item != data.itemType;
});

pushCount += data.source.length;

// no undo-redo for synchronization, and the stack is lost after undo-redo
Expand Down Expand Up @@ -309,6 +313,10 @@ package org.restfulx.controllers {
throw new Error(error);
}));
}

if (pushCount == 0 && pushModels.length == 0) {
notifyPushEnd();
}
}

protected function onDirtyFault(info:Object, token:Object = null):void {
Expand Down

0 comments on commit 41bc80d

Please sign in to comment.