Skip to content

Commit

Permalink
Added Observe and included support for it in binding using the [Binda…
Browse files Browse the repository at this point in the history
…ble(observable)] tag. Should increase the speed of data-binding and make the system faster (also allows for global listening to property changes by class type).
  • Loading branch information
Jacob Wright committed Feb 10, 2010
1 parent 27b075a commit 211e513
Show file tree
Hide file tree
Showing 12 changed files with 674 additions and 67 deletions.
2 changes: 1 addition & 1 deletion project/.actionScriptProperties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<actionScriptProperties mainApplicationPath="flightaf.as" projectUUID="3d4a815f-db06-4a5e-b5be-cb87fd729505" version="6">
<actionScriptProperties mainApplicationPath="flightaf.as" projectUUID="b11add20-5251-452f-b2cb-b0937091803b" version="6">
<compiler additionalCompilerArguments="-keep-as3-metadata+=Argument,Inject,Binding,PropertyListener,EventListener -compute-digest=false" autoRSLOrdering="true" copyDependentFiles="false" flex3CompatMode="true" fteInMXComponents="false" generateAccessible="false" htmlExpressInstall="true" htmlGenerate="false" htmlHistoryManagement="false" htmlPlayerVersionCheck="true" includeNetmonSwc="false" outputFolderPath="bin" sourceFolderPath="src" strict="true" targetPlayerVersion="0.0.0" useApolloConfig="false" useDebugRSLSwfs="true" verifyDigests="true" warn="true">
<compilerSourcePath/>
<libraryPath defaultLinkType="1">
Expand Down
7 changes: 5 additions & 2 deletions project/.flexLibProperties
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@
<flexLibProperties includeAllClasses="false" version="1">
<includeClasses>
<classEntry path="flexUnitTests.BindingTestSuite"/>
<classEntry path="flexUnitTests.binding.BindTest"/>
<classEntry path="flexUnitTests.binding.BindingTest"/>
<classEntry path="flexUnitTests.binding.ObservingBindTest"/>
<classEntry path="flight.binding.Bind"/>
<classEntry path="flight.binding.Binding"/>
<classEntry path="flight.commands.CommandHistory"/>
<classEntry path="flight.commands.IAsyncCommand"/>
<classEntry path="flight.commands.ICommand"/>
Expand Down Expand Up @@ -49,6 +53,7 @@
<classEntry path="flight.net.IResponse"/>
<classEntry path="flight.net.Response"/>
<classEntry path="flight.net.ResponseStatus"/>
<classEntry path="flight.observers.Observe"/>
<classEntry path="flight.progress.IProgress"/>
<classEntry path="flight.progress.Progress"/>
<classEntry path="flight.services.Service"/>
Expand All @@ -64,8 +69,6 @@
<classEntry path="flight.view.MediatorMap"/>
<classEntry path="flight.vo.IValueObject"/>
<classEntry path="flight.vo.ValueObject"/>
<classEntry path="flight.binding.Binding"/>
<classEntry path="flexUnitTests.binding.BindTest"/>
</includeClasses>
<includeResources/>
<namespaceManifests>
Expand Down
2 changes: 1 addition & 1 deletion project/.settings/com.adobe.flexbuilder.project.prefs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#Thu Jan 21 10:51:32 MST 2010
#Thu Feb 04 17:35:57 MST 2010
eclipse.preferences.version=1
upgradeSDK/fb4=
useFlex3CompatibilityMode/fb4=true
Binary file modified project/bin/flight-framework.swc
Binary file not shown.
2 changes: 2 additions & 0 deletions project/src/flexUnitTests/BindingTestSuite.as
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@ package flexUnitTests
{
import flexUnitTests.binding.BindTest;
import flexUnitTests.binding.BindingTest;
import flexUnitTests.binding.ObservingBindTest;

[Suite]
[RunWith("org.flexunit.runners.Suite")]
public class BindingTestSuite
{
public var bindingTest:BindingTest;
public var bindTest:BindTest;
public var observingBindTest:ObservingBindTest;
}
}
44 changes: 44 additions & 0 deletions project/src/flexUnitTests/binding/BindTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,50 @@ package flexUnitTests.binding
setTimeout(Async.asyncHandler(this, checkEmptyDict, 500, params), 10, dummyEvent);
}

[Test(async)]
public function testMemoryReleaseListener():void
{
var dict:Dictionary = new Dictionary(true);
var temp:TestObject = obj1.clone();
dict[temp] = true;

newValue = "";
Bind.addListener(this, valueChange, temp, "str");

assertEquals("Listener not called or called incorrectly", "TestStr1", newValue);

temp.str = "TestChange";
assertEquals("Listener not called or called incorrectly", "TestChange", newValue);


System.gc();

var params:Object = {dict: dict, msg: "Object was not removed from memory after there were no references to it"};
setTimeout(Async.asyncHandler(this, checkEmptyDict, 500, params), 10, dummyEvent);
}

[Test(async)]
public function testMemoryReleaseEventListener():void
{
var dict:Dictionary = new Dictionary(true);
var temp:TestObject = obj1.clone();
temp.obj = temp.clone();
dict[temp] = true;

eventTriggered = 0;
var binding:Binding = Bind.bindEventListener("customChange", onChange, temp, "obj");
temp.obj.custom = "test";
assertEquals("The event was not bound correctly or triggered.", 1, eventTriggered);
temp.obj = new TestObject();
temp.obj.custom = "test2";
assertEquals("The event was not triggered when the new dispatcher dispatched.", 2, eventTriggered);

System.gc();

var params:Object = {dict: dict, msg: "Object was not removed from memory after there were no references to it"};
setTimeout(Async.asyncHandler(this, checkEmptyDict, 500, params), 10, dummyEvent);
}

private function checkEmptyDict(event:Event, params:Object):void
{
for (var i:Object in params.dict) {}
Expand Down
19 changes: 18 additions & 1 deletion project/src/flexUnitTests/binding/BindingTest.as
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,27 @@ package flexUnitTests.binding
assertEquals("Number did not get set to correctly", 20, obj2.num);
}

[Test]
public function testMixedPath():void
{
var binding:Binding = new Binding(this, setter, obj1, "str");

assertEquals("Listener not called or called incorrectly", "TestStr1", setterValue);

obj1.str = "TestChange";
assertEquals("Listener not called or called incorrectly", "TestChange", setterValue);
}

protected var setterValue:Object;
protected function setter(value:Object):void
{
setterValue = value;
}

[Test]
public function testListener():void
{
var binding:Binding = new Binding(valueChange, null, obj1, "str");
var binding:Binding = new Binding(this, valueChange, obj1, "str");

assertEquals("Listener not called or called incorrectly", "TestStr1", newValue);

Expand Down
Loading

0 comments on commit 211e513

Please sign in to comment.