Nodejs wo callback[Khoa Tran]
Upcoming SlideShare
Loading in...5
×
 

Nodejs wo callback[Khoa Tran]

on

  • 507 views

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

Statistics

Views

Total Views
507
Views on SlideShare
507
Embed Views
0

Actions

Likes
0
Downloads
2
Comments
0

0 Embeds 0

No embeds

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Nodejs wo callback[Khoa Tran] Nodejs wo callback[Khoa Tran] Presentation Transcript

  • w/o callback Presented by: Khoa Tran Jan 7th 2014
  • Agenda • Why I don’t like callbacks • Is there good alternative to write async code? • Generator • Get rid of callbacks
  • Why I don’t like callbacks? 1. Lots of nesting functions 2. Variable scope confusion 3. Handle exceptions everywhere Writing readable code is hard!!!
  • Is there good alternative? • Async • Fiber • Promise/Q • Co
  • 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
  • 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.
  • Get rid of callbacks Clone demo source at: https://github.com/tvkkpt/jsmeetup-demo
  • What to do next Join this open-source project: https://github.com/visionmedia/co
  • 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
  • Thank you and HAPPY NEW YEAR!