The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

iolalog (10) [Avatar] Offline
Hi Yan

This question is a little off-topic, but just looking for a few pointers if you find the time. I'm a programming newbie (comming from the business intelligence / data warehousing world), and recently completed this Node.js course (that was great):

The course looks at promises, async / await and so on, but not co, function* and other modules / techniques you use here. Do you know any good resources to look at comparing the ways one can create asynchronous code in Node.js?

And somewhat realted, ways of creating push for serverless webapplications? I'm asking because I have a IoT startup on the side where I need to push IoT events to a client application, and I prefer to avoid native apps and servers if I can. For that reason I'd like to be able to push events to a webapp (and build it as a Progressive Web App to further approach native with a webapp).

Yan Cui (73) [Avatar] Offline
Hi Olav,

For async techniques for Node.js, if you're using Node.js 8.10 with Lambda then you can use the new "async" and "await" keywords. You can see some examples in the announcement here.

As for the use of generator functions (ie. when it's declared with function*) and co, I find the co library's github page is the best place to go.

For push, check out AWS IOT Core service, it supports websockets so you can use it easily from a progressive web app.

Hope this helps.

iolalog (10) [Avatar] Offline

joebowbeer (14) [Avatar] Offline
I also came to this forum to suggest mentioning the availability of async/await in lambdas running on node8, but now I see that this has already been addressed in the forum.

I suggest finding a way to alert the student about the presence of these updates, as there are likely to be a lot of them, knowing how rapidly this area is developing.

Can you add footnotes to the transcription? And/or add popup alerts to the videos?
Petar Korudzhiev (2) [Avatar] Offline
Hi Yan,

I am trying to reproduce what you are doing in the course in my own example project but using ES7 syntax (import/export, async/await ... etc.) The problem I came is when try to convert the usage of middy. It seems it is not ready for this step already.

I guess this is one of the reasons why you use
Yan Cui (73) [Avatar] Offline
Hi Petar,

It is indeed a problem with Middy and they're looking to fix it. In the meantime, you can still use async-await everywhere else outside of the main handler function itself (the entry point), which still needs the callback. So one thing you can do is to move all the logic into function async functions, and leave the handler function itself as a one liner that calls the internal functions and make them work with the callback function.

ehemmerlin (3) [Avatar] Offline
Hi Yan,
We talked together at ServerlessDays Milan and you asked me to put a message on the forum to get the repo of the "Production-Ready Serverless" code using async/await functions. Thanks a lot for all the good work you do on this subject.
Yan Cui (73) [Avatar] Offline
Hi, have a look at this repo which should give you a good sense what the demo app looks like with async-await. It doesn't have all the same modules, but should give you a pretty good idea nonetheless.