These are mostly little things, but since Conduit is Open Source, we are able to incorporate them into how Conduit works, and give us some new tools to use when we set up Remoting.
One of the first enhancements I made, was around the fact that every time Flex invokes a CFC through Remoting, it gets created on every request. Quite often, this is simply not necessary, as the CFC in question has no state, or maybe you want the CFC to maintain state, but you have to jump through some hoops to get that to happen.
In Conduit, you can now set a:
<cfcomponent remoteScope="application" >...</cfcomponent>
...and the CFC will be stored inside the specified shared scope.
For example, here is a CFC that gets stored in the session scope when invoked, and keeps a simple incrementing number each time its remote method gets called:
<cfcomponent hint="proxy stored in a share scope" output="false" remoteScope="session">
instance.value = 1;
<cffunction name="getIncrementingValue" hint="returns a value, and increments it by 1" access="remote" returntype="numeric" output="false">
<cfreturn instance.value++ />
So you can see here how we are able to maintain state between calls, within a single CFC.
The other enhancements I made, revolve around passing null values back and forth from AS3 Objects, and ColdFusion.
As we all know, there is no null as such in ColdFusion, which can make dealing with null values from Flex slightly problematic.
I've added two new enhancements to <cfproperty> for Value Objects to help with this issue - nullvalue and nullmethod.
nullvalue provides a value for a given property to be used when a null value is found in a Flex AS3 object coming down to ColdFusion. This is particularly applicable when using getter/setters for your properties on your ColdFusion Value Objects.
<cfcomponent output="false" alias="tests.cfml.cfc.model.Basic">...will set 'Date' to the 1-1-1900 if the AS3 Object's 'date' property is null. Also, if sending data back up to Flex from CF, the 'date' property is set to null on the Flex side, if the date value is 1-1-1900. This gives you a type safe way of dealing with null values coming down from Flex.
<cfproperty name="date" type="date" nullvalue="1-1-1900">
<cffunction name="getDate" access="public" returntype="date" output="false">
<cfreturn instance.date />
<cffunction name="setDate" access="public" returntype="void" output="false">
<cfargument name="date" type="date" required="true">
<cfset instance.date = arguments.date />
The nullMethod option for dealing with null values becomes more useful when dealing with object composition in Value Objects.
The nullmethod attribute specifies a method on the CFC to be fired, when encountering a null value for the specified method, e.g.
<cfcomponent output="false" alias="tests.cfml.cfc.model.Basic">
<cfproperty name="simple" type="tests.cfml.cfc.model.Simple" nullmethod="removeSimple">
<cffunction name="setSimple" access="public" returntype="void" output="false">
<cfargument name="Simple" type="Simple" required="true">
<cfset instance.Simple = arguments.Simple />
<cffunction name="removeSimple" hint="remove simple" access="public" returntype="void" output="false">
<cfset StructDelete(instance, "Simple") />
So in this case, whenever the property 'Simple' comes back from Flex as null, the method 'removeSimple' is called instead of attempting to set the property.
Now you can start to see what we can do with Conduit, since we can control all aspects of the Remoting process. So the question is - if you could change any aspect of ColdFusion <=> Flex Remoting, what would it be? Let me know, and we can see if we can incorporate it into Conduit!
If you want to read more, check out Differences between Conduit and ColdFusion remoting, in the Conduit documentation.