iolalog (10) [Avatar] Offline
#1
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): https://www.udemy.com/the-complete-nodejs-developer-course-2/

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).

Regards,
Olav
Yan Cui (68) [Avatar] Offline
#2
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.

Cheers,
iolalog (10) [Avatar] Offline
#3
Thanks!

Regards,
Olav
joebowbeer (14) [Avatar] Offline
#4
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.

https://serverless.com/blog/aws-lambda-node-8-support-what-changes-serverless-developers/

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
#5
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. https://github.com/middyjs/middy/issues/198

I guess this is one of the reasons why you use https://www.npmjs.com/package/co
Yan Cui (68) [Avatar] Offline
#6
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.

Cheers,
ehemmerlin (3) [Avatar] Offline
#7
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.
Eric
Yan Cui (68) [Avatar] Offline
#8
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.