lecosson / assql

Automatically exported from code.google.com/p/assql
0 stars 0 forks source link

MySqlResponser: Having it as class is not appropriate #25

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. MySqlResponser
2.
3.

What is the expected output? What do you see instead?
One should not aim the output as ArrayCollection only.

What version of the product are you using? On what operating system?
2.3 / 2.4

Please provide any additional information below.
I am working for a small to medium level application where for different
calls, I need different responder. I tried extending MySqlResponser, but
then I can not override the two methods. And receiving all the output in
the MySqlResponser's method's will be too complicated (where I am receiving
output from 10+ tables).

The appropriate solution will be the one declaring MySqlResponser as interface.
The best and ideal solution would be one where all the output will be
handled by IResponder implementing classes directly.
public function result(data:Object):void
{
    //TODO: implement function
    var list:ArrayCollection = data.result as ArrayCollection;
}

public function fault(info:Object):void
{
    //TODO: implement function
    Alert.show("In Fault:Responder");
}

Also, if you can provide some functionality like this:
var call : AsyncToken = someMethodCall();
call.addResponder( responder );

where someMethodCall() is:
public function someMethodCall():Object/IMessage
{
    sqlService.send("SELECT * FROM tbl_flat");
}

Let me know, if you could not understand the problem exactly.
Thanks.

Original issue reported on code.google.com by manuraj....@gmail.com on 26 May 2008 at 12:56

GoogleCodeExporter commented 9 years ago
Statement and MySqlService use IResponder. You should be able to create your own
responder class to handle the responses as needed.

Example:

public class MyResponder implements IResponder
{
    public function result(data:Object):void {
        var evt:MySqlEvent = MySqlEvent(data);

        if ( evt.type == MySqlEvent.RESULT ) {
            //handle queries
            var list:ArrayCollection = evt.resultSet.getRows();
        }
        else is ( evt.type == MySqlEvent.RESPONSE {
            //handle updates    
        }
    }

    public function fault(info:Object):void {
        var evt:MySqlErrorEvent = MySqlErrorEvent(info);
        //handle error.
    }

}

I am not 100% sure I completly understand your problem though. 

I am looking into making queries and updates dispatch the same event because 
having
both RESULT and RESPONSE events seems to only cause problems.

I do like the idea of using AsyncTokens too, I am also looking into that.

Original comment by macl...@gmail.com on 26 May 2008 at 1:07

GoogleCodeExporter commented 9 years ago

Original comment by macl...@gmail.com on 27 May 2008 at 4:16

GoogleCodeExporter commented 9 years ago

Original comment by macl...@gmail.com on 27 May 2008 at 5:26

GoogleCodeExporter commented 9 years ago

Original comment by macl...@gmail.com on 9 Jun 2008 at 1:33