From 74e0a2159afbce53658acf97c96b0b2825757cf1 Mon Sep 17 00:00:00 2001 From: Wil Chung Date: Tue, 29 Jan 2013 13:33:37 -0800 Subject: [PATCH] Added progress sugar documentation in README.md --- README.md | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/README.md b/README.md index 4eebec11..9ab3affb 100644 --- a/README.md +++ b/README.md @@ -367,6 +367,36 @@ foo() }) ``` +### Progress Notification + +It's possible for some promises to report their progress, especially +if it's a task that takes a long time, or iterates. Not all promises +may implement progress notifications. + +```javascript +foo() +.then(function (value) { + // Success processing foo and getting a value +}, function(err) { + // There was an error, and we get the reason for error +}, function(progress) { + // We get notified of foo()'s progress as it's executed +}) +``` + +like `fail`, Q also provides a shorthand for progress callbacks +called `progress`. + +```javascript +foo() +.then(function (value) { + // Success processing foo() +}).fail(function(err) { + // There was an error +}).progress(function(prog) { + // We get notified of foo'd progress +}) +``` ### The End