Join Errors?

7 views
Skip to first unread message

Robert

unread,
Oct 23, 2010, 3:58:00 AM10/23/10
to FuturesJS
Hey All,

I'm new to this FutureJS thing so bear with me....I followed the API
as per the github page but I still can't seem to get what I want.
Node.js is throwing up an error regarding my code and I can't figure
out what's wrong with it:

http://gist.github.com/641916

Help would be much appreciated!

AJ ONeal

unread,
Oct 23, 2010, 10:46:49 AM10/23/10
to futures-j...@googlegroups.com
Try this:
http://gist.github.com/642253

I rewrote your code twice: once just how you had it, another time more like I might have written it if I weren't trying to debug it so much.

I would recommend not using "promisify()" and "subscribify". In fact, I removed them from the documentation just now.

I was trying to make an argument wrapper that worked well for things like jQuery that have the arguments in an unpredictable order... but it failed.

Sorry about that.

Also, I posted the snippet in the node-examples directory on future's github.

AJ ONeal



--
Please use prefixes: [Pony] Feature requests, [TestCase] Test cases, [Bug] if you're lazy. If you have contract work or position for FuturesJS devs, prefix [Bounty] or [Job].
-----
To post to this group, send email to futures-j...@googlegroups.com
To unsubscribe from this group, send email to
futures-javascr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/futures-javascript?hl=en

Robert Navarro

unread,
Oct 23, 2010, 3:40:53 PM10/23/10
to futures-j...@googlegroups.com
Thanks for the tips AJ! I'll study it and look it over.
--
Robert Navarro

Tauren Mills

unread,
Oct 23, 2010, 5:59:30 PM10/23/10
to futures-j...@googlegroups.com
AJ,

Nice to hear you're deprecating promisify and subsribify as well. Now that you mention them, it seems they were more functions I thought I would never use.

Tauren

AJ ONeal

unread,
Oct 25, 2010, 9:43:40 PM10/25/10
to futures-j...@googlegroups.com

How did it go Robert? Figuring things out okay?

AJ

Sent from my Google Android

>>> futures-javascr...@googlegroups.com<futures-javascript%2Bunsu...@googlegroups.com>


>>> For more options, visit this group at
>>> http://groups.google.com/group/futures-javascript?hl=en
>>>
>>
>> --
>> Please use prefixes: [Pony] Feature requests, [TestCase] Test cases, [Bug]
>> if you're lazy. If you have contract work or position for FuturesJS devs,
>> prefix [Bounty] or [Job].
>> -----
>> To post to this group, send email to futures-j...@googlegroups.com
>> To unsubscribe from this group, send email to

>> futures-javascr...@googlegroups.com<futures-javascript%2Bunsu...@googlegroups.com>


>> For more options, visit this group at
>> http://groups.google.com/group/futures-javascript?hl=en
>>
>
>
>
> --
> Robert Navarro
>

Robert Navarro

unread,
Oct 26, 2010, 10:30:42 AM10/26/10
to futures-j...@googlegroups.com
Hey AJ,

Haven't had time to really delve deep into the code. Been busy with school stuff, hopefully I'll have more time later this week to really get a good crack at it. I'll let you know =D
--
Robert Navarro
+1 (530) 868-6237
http://www.crshman.com

Master Chief of Phiivo Inc.
http://www.phiivo.com
Finding Innovation in Everything

Robert Navarro

unread,
Nov 11, 2010, 12:53:59 AM11/11/10
to futures-j...@googlegroups.com
Hey AJ,

So this is what I eventually came up with, definitely still a work in progress and i'm sure my amateur coding abilities will present themselves.

AJ ONeal

unread,
Nov 11, 2010, 1:07:14 AM11/11/10
to futures-j...@googlegroups.com
That seems to be a common pattern, actually.

I've been considering changing Futures.join to work that way (see previous post Promises/KISS)

j = Futures.join();
j.add(promise);
j.add(promise2);
j.add(promise3);
j.when(doStuff);
j.add(promise4); // throws exception

On another note, if you haven't watched yuiblog.com/crockford, I highly suggest it.


Due to "variable hoisting" and broken object enumeration this snippet won't always work how you expect:

for(var i in obj) {
    console.log(obj[i]);
}

Instead try this:

`var` should be hoisted to the top of the function, not in a for loop:
var i;
for (i = 0; i < 10; i += 1) { /* do stuff */ }

Objects should be accessed only by their own properties
Object.keys(obj).forEach(function (key) {
    console.log(obj[key]);
});

If you want to use Object.keys and .forEach in the browser check out global-es5.js which is part of persevere.
You just have to remove the "require('JSON')" from the last line of the script and it will work in the browser.

AJ ONeal

Robert Navarro

unread,
Nov 11, 2010, 1:10:58 AM11/11/10
to futures-j...@googlegroups.com
Thanks for the advice!

I'll certainly look into that video you linked.
Reply all
Reply to author
Forward
0 new messages