Hacker News new | past | comments | ask | show | jobs | submit login

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!




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: