sorry for a small mistake

On Thu, Aug 23, 2012 at 11:31 PM, Tony Huang <[email protected]> wrote:

> I'm transforming my game server into Wind.js style. And it's really
> painless and smooth.
>
> Wind.js has already provided the Wind.Async.Bindings.fromStandard and
> Wind.Async.Bindings.fromCallback stubs to help you integrate existing codes.
>
> For instance, I already have a EntityStore class which provides standard
> style interface:
> EntityStore.prototype = {
>   'get': function(cb) {
>     //...
>   },
>   'save': function(entity,cb) {
>     //...
>    }
> };
> In order to make it usable in Wind.js, I just added following codes at the
> end of the module:
> ['get', 'save'].forEach(function(method) {
>   EntityStore.prototype[method + 'Async'] =
> Wind.Async.Binding.fromStandard(EntityStore.prototype[method]);
> });
>
> As a result, I can access these methods in Wind.js easily in this way:
>
> var users = new EntityStore('user');
> var currentUser = $await(users.get(userId));
>
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
should be:
var currentUser = $await(users.getAsync(userId));

> It's quite easy.
>
> But in the other hand, Wind.js hasn't provide the reverse operation, so I
> added 2 method to the library:
> - Wind.Async.Binding.toStandard
> - Wind.Async.Binding.toCallback
>
> So I can replace my code method by method without any overhead:
> My original code might be:
> function wearEquipment(characterId, equipmentId, cb) {
>   //..... deep levels of callbacks
> }
> After refactoring, my code comes to:
> var wearEquipmentAsync = eval(Wind.compile('async', function(characterId,
> equipmentId) {
>   // code in synchronised style
> });
> var wearEquipment = Wind.Async.Binding.toStandard(wearEquipmentAsync);
>
> Completely the same interface, the same function, but better-looking code.
>
>
> On Thu, Aug 23, 2012 at 12:55 AM, Bruno Jouhier <[email protected]>wrote:
>
>> On Wednesday, August 22, 2012 12:55:41 PM UTC+2, Dominic wrote:
>>>
>>> this is all very clever, but do code transformations really make
>>> callbacks easier?
>>>
>>
>> Take the streamline tutorial (doc:
>> https://github.com/Sage/streamlinejs/blob/master/tutorial/tutorial.mdsource:
>> https://github.com/Sage/streamlinejs/blob/master/tutorial/tuto7-parallel._js)
>> and write it with plain callbacks.
>>
>>
>>  --
>> Job Board: http://jobs.nodejs.org/
>> Posting guidelines:
>> https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
>> You received this message because you are subscribed to the Google
>> Groups "nodejs" group.
>> To post to this group, send email to [email protected]
>> To unsubscribe from this group, send email to
>> [email protected]
>> For more options, visit this group at
>> http://groups.google.com/group/nodejs?hl=en?hl=en
>>
>
>
>
> --
> ------------------------------------------------------
> Tony Huang    [email protected]
>                      [email protected]
>                      [email protected]
>



-- 
------------------------------------------------------
Tony Huang    [email protected]
                     [email protected]
                     [email protected]

-- 
Job Board: http://jobs.nodejs.org/
Posting guidelines: 
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
You received this message because you are subscribed to the Google
Groups "nodejs" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/nodejs?hl=en?hl=en

Reply via email to