News for hackers. Stuff that matters.
Re:Async and Await by sriku on Thursday June 02, 2016 @03:33PM (#11825387)
Been using async/await like sweetjs macro "task" in production for around 1.5yrs (https://github.com/srikumarks/cspjs). This code would read -

    task getUsersWithFriends() {
        users <- getUsers();
        catch (e) {
            return trySomethingElse(users);
        }
        // Everything below is protected by the catch above.
        withFriends <- filterUsersWithFriends(users);
        return withFriends;
    }
.. with errors propagating to nodejs style callbacks automatically. No need for overheads like "promisifyAll" either. cspjs turns the task into a state machine. Better semantics for catch and finally where you can retry operation from within catch clause (ex: exponential backoff).

disclosure: author of cspjs. couldn't help shameless plug since this was being touted as the "future" in the original post!

There are no comments on this comment yet.