These are chat archives for jdubray/sam

3rd
Jul 2018
Jean-Jacques Dubray
@jdubray
Jul 03 2018 08:52
I worked on a very interesting little problem this past week: how do you add a retry extension to your favorite API call library (e.g. request promise). The idea is to just add a couple parameters to the rp options: retryCount, retryInterval. I didn't want to use SAM because I felt people would think that's the only coding pattern I know, so I went on writing it with es6 promises. It's doable but I found out how easier it is to reason about and extend for just a handful of additional lines of code. If you are still on the fence about SAM, this could certainly convince you to use it. Since this was an extension to request-promise, the SAM loop was within a single function and had a single action, make the request. I'd be really interested to know what people think about this problem if you have some time to try it, because that's truly a blueprint for longrunning, stateful functions. Bonus points if you also compare it to generators.