Your SlideShare is downloading. ×
  • Like
Nodejs wo callback[Khoa Tran]
Upcoming SlideShare
Loading in...5
×

Thanks for flagging this SlideShare!

Oops! An error has occurred.

×

Now you can save presentations on your phone or tablet

Available for both IPhone and Android

Text the download link to your phone

Standard text messaging rates apply

Nodejs wo callback[Khoa Tran]

  • 268 views
Published

You can find us at: …

You can find us at:
http://www.meetup.com/JavaScript-Ho-Chi-Minh-City/
https://www.facebook.com/JavaScriptHCMC?ref=hl https://plus.google.com/communities/116105314977285194967

Published in Technology , Business
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
268
On SlideShare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. w/o callback Presented by: Khoa Tran Jan 7th 2014
  • 2. Agenda • Why I don’t like callbacks • Is there good alternative to write async code? • Generator • Get rid of callbacks
  • 3. Why I don’t like callbacks? 1. Lots of nesting functions 2. Variable scope confusion 3. Handle exceptions everywhere Writing readable code is hard!!!
  • 4. Is there good alternative? • Async • Fiber • Promise/Q • Co
  • 5. Generator • “In computer science, a generator is a special routine that can be used to control the iteration behaviour of a loop” - From wikipedia Executor Generator … next() … val1 process val1 yield val1 next() process val2 … … val2 yield val2
  • 6. Generator in node.js • Only supported in version 0.11.x and above. For now, you have to build and install node.js from Github. • In addition, execute code with --harmony flag.
  • 7. Get rid of callbacks Clone demo source at: https://github.com/tvkkpt/jsmeetup-demo
  • 8. What to do next Join this open-source project: https://github.com/visionmedia/co
  • 9. About us Author: Khoa Tran Find me at: tvkkpt@gmail.com Presentation made for JavaScript HCMC Meetup You can find us at: http://www.meetup.com/JavaScript-Ho-Chi-Minh-City/ https://www.facebook.com/JavaScriptHCMC?ref=hl https://plus.google.com/communities/116105314977285194967
  • 10. Thank you and HAPPY NEW YEAR!