ISSUE-59: Promises Programming Pattern Verification
Promises Programming Pattern Verification
- State:
- CLOSED
- Product:
- design for Web Crypto API
- Raised by:
- Israel Hilerio
- Opened on:
- 2013-11-14
- Description:
- From email thread (see attachment):
http://lists.w3.org/Archives/Public/public-webcrypto/2013Nov/0023.html
Generally speaking, there seem to be two possible Promises programming patterns Example1 vs. Example2. I believe Example1 captures the programming pattern we are proposing: (using arrows to show indentation):
EXAMPLE1 (does this imply single operations):
CryptoPromise1.then(…
CryptoPromise2.then(…
CryptoPromise3.then(…)
),
failureFunctionPromise1(…)
);
vs.
EXAMPLE2 (is this needed for multi-part operations)?
CryptoPromise1.then(...,failureFunctionPromise1(…)).then(…).then(…);
Can we validate that EXAMPLE1 and not EXAMPLE2 is the expected pattern and that this model will not support multi-part on the first release of the spec.
Also, per our previous conversation (a couple of weeks back) the expected error handling is ideally exception free and relies on the promise failure handler model (EXAMPLE1). In this model, all error handling can be done inside the failureFunctionPromise1() function vs. the exception based pattern outlined in EXAMPLE3 which breaks the error handling into two blocks (exceptions vs. failed promises):
EXAMPLE3:
try {
CryptoPromise1.then(…
CryptoPromise2.then(…
CryptoPromise3.then(…)
),
failureFunctionPromise1(
// handle promises failures
)
);
} catch(e) {
//handle exception failures
}
- Related Actions Items:
- No related actions
- Related emails:
- W3C Web Crypto WG - closing ISSUE 59 ? (from Virginie.GALINDO@gemalto.com on 2014-01-09)
- crypto-ISSUE-59: Promises Programming Pattern Verification [design for Web Crypto API] (from sysbot+tracker@w3.org on 2013-11-14)
Related notes:
REPLY: http://lists.w3.org/Archives/Public/public-webcrypto/2013Nov/0024.html
ANSWER: http://lists.w3.org/Archives/Public/public-webcrypto/2013Nov/0025.html
Expected usage pattern:
http://lists.w3.org/Archives/Public/public-webcrypto/2013Nov/att-0023/CryptoPromises.sample.txt
After discussing this issue at TPAC F2F we agreed to follow the model proposed in Example#2:
CryptoPromise1.then(...,failureFunctionPromise1(...)).then(...).then(...);
(see http://lists.w3.org/Archives/Public/public-webcrypto/2013Nov/att-0054/ActualProposedUsagePattern.txt):
This will only deal with a single part model.
Correct link to previous note:
http://lists.w3.org/Archives/Public/public-webcrypto/2013Nov/att-0054/ActualProposedUsagePattern.txt
I'm good with the explanations that were provided during the F2F.
Israel Hilerio, 10 Feb 2014, 20:13:27Display change log