Labs/Jetpack/JEP/11: Difference between revisions

m
Line 31: Line 31:
Because of the asynchronous nature of this API, its operations communicate their statuses and results to callers via callbacks.  In the context of simple storage, a callback is either a function or an object that defines the methods <code>onResult</code> and <code>onError</code>.  If a callback is a function, it is called when its associated asynchronous operation successfully completes.  If a callback is an object, its <code>onResult</code> method (if defined) is called when the operation successfully completes, and its <code>onError</code> method (if defined) is called when an error occurs during the operation.  This allows callers to provide a simple function in the common case; only if callers wish to be notified of errors do they need to use the more verbose object form.
Because of the asynchronous nature of this API, its operations communicate their statuses and results to callers via callbacks.  In the context of simple storage, a callback is either a function or an object that defines the methods <code>onResult</code> and <code>onError</code>.  If a callback is a function, it is called when its associated asynchronous operation successfully completes.  If a callback is an object, its <code>onResult</code> method (if defined) is called when the operation successfully completes, and its <code>onError</code> method (if defined) is called when an error occurs during the operation.  This allows callers to provide a simple function in the common case; only if callers wish to be notified of errors do they need to use the more verbose object form.


In this proposal, <code>onResult</code> refers to either the function form or the <code>object.onResult</code> form.  Since there is only one form for errors, <code>onError</code> refers to the <code>object.onError</code> form.
In the remainder of this proposal, <code>onResult</code> is shorthand for either the function form or the <code>object.onResult</code> form.  Since there is only one form for errors, <code>onError</code> is shorthand for the <code>object.onError</code> form.


The arguments passed to <code>onResult</code> and <code>onError</code> depend on the API method to which the callback is passed.  Each method's description below indicates how it calls its callback.
The arguments passed to <code>onResult</code> and <code>onError</code> depend on the API method to which the callback is passed.  Each method's description below indicates how it calls its callback.
Confirmed users
764

edits