New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support node-style callbacks #125
Conversation
Looks good! Could you give a couple of "real-life" examples of the usage? |
tl;dr Using the Redis client library Of course. Here's one where I use it: https://github.com/abesto/shopping-list/blob/master/routes/tab.js This is basically an end-point of a REST API. Walking through the
Edit: oh, you mean in the readme? |
I'm not sure I like the name Perhaps call it |
@00Davo I'd prefer to call it To me, the Bottom line: I still prefer |
I guess "node-style callbacks" are well-known enough to warrant for the name The example code is pretty cool and I also like the fact that you only need to deal with errors in a single spot. And yes, I'm a kind-of-a Haskellist too, having written reactive-bacon before starting to work on bacon.js. I hope you don't mind if I do some code review for you. The code looks very good, but some simplifications could probably be made. Looking at the
Now because key is really just a constant value, you could still simplyfy to
Also, on the last line, you have
While you could have instead just
Right? Oh, and you can use plain The bottom line is, I'm pretty convinced we should include |
Wow, thanks for the suggestions :) You're right on all counts. I guess bacon.js is such a shiny hammer, even constants look like nails. I've added two simple examples (with and without error), using the example for |
Yeah, it's quite a hammer :) I recently bought a Fein Multimaster and been trying to fit it to all kinds of jobs I've done just fine without the new tool. Actually I was thinking of more realistic examples, involving some real Node.js APIs. That would also serve to demonstrate the partial application capabilities. |
How about this? Uses a real node.js api, shows partial application and error handling, and still quite simple to understand. |
That's it! Merging. A blog post on server-side Bacon would be nice too. It would be nice to demonstrate how you can avoid the infamous callback hell, while taking care of error handling in a reliable and simple way. The problem is that I haven't done any serious node dev for some time and feel a bit lacking in credibility there, like "if I did node dev, this is how I'd do it".. Well, I should probably do my next server in node+bacon. |
Support node-style callbacks
I'm planning to rewrite the whole shoppinglist thing with bacon. I'll probably write a post about what I learned in the process, thanks for the idea! (and the merge :)) |
I'm happy with the name I'd also very much like to see an example of Bacon.js being applied on server-side with Node, so that'd be good. |
Hi, I'm trying to use BaconJS for the first time for the following use case:
Looking at http://abesto.net/bacon-js-on-the-server/ and http://howtonode.org/node-redis-fun
So the above would be:
do some |
Your code above creates a hash of Properties. What are you trying to achieve? Also, Issues are not really a support forum. I suggest you use Stack Overflow, which is better for sharing problems/solutions. |
Hey! I started playing with Bacon after attending your workshop at mloc.js. I really like it so far. Here's one addition I'd find useful: support for Node.js-style callbacks. This makes bacon.js much easier to use on the server side.
I realize that this is a bit like the jQuery adapter so maybe it should be in a separate package, but the readme explicitly mentions that bacon.js works fine on the server; this looks like a basic requirement for node.js usage.
Hope you like the idea; please give feedback on the implementation if you'd prefer some other solution :)
Keep up the great work! 馃憤