KISSY.Promise
Promise constructor. This class should not be instantiated manually. Instances will be created and returned as needed by KISSY.Defer#promise
defined in: promise.js
Class
- KISSY.Promise (v)
Methods
- KISSY.Promise. all (promises) <static> return a new promise which is resolved when all promises is resolved and rejected when any one of promises is rejected
- fail (rejected) call rejected callback when this promise object is rejected
- fin (callback) call callback when this promise object is rejected or resolved
- KISSY.Promise. isPromise (obj) <static> whether the given object is a promise
- isRejected () whether the given object is a rejected promise
- KISSY.Promise. isRejected (obj) <static> whether the given object is a rejected promise
- KISSY.Promise. isResolved (obj) <static> whether the given object is a resolved promise
- isResolved () whether the given object is a resolved promise if it is resolved with another promise, then that promise needs to be resolved as well.
- then (fulfilled, rejected) register callbacks when this promise object is resolved
- KISSY.Promise. when (obj, fulfilled, rejected) <static> register callbacks when obj as a promise is resolved or call fulfilled callback directly when obj is not a promise object
Class Detail
-
KISSY.Promise (v)Promise constructor. This class should not be instantiated manually. Instances will be created and returned as needed by KISSY.Defer#promise
- Parameters
-
- [ v ] promise 's resolved value
Methods Detail
-
return a new promise which is resolved when all promises is resolved and rejected when any one of promises is rejected
- Parameters
-
- promises {KISSY.Promise[]} list of promises
-
fail (rejected) view sourcecall rejected callback when this promise object is rejected
- Parameters
-
- rejected {Function(*)} called with rejected reason
- Returns
-
- {KISSY.Promise} a new promise object
-
fin (callback) view sourcecall callback when this promise object is rejected or resolved
- Parameters
-
- callback {Function} the second parameter is true when resolved and false when rejected
-
whether the given object is a promise
- Parameters
-
- obj the tested object
-
isRejected () view sourcewhether the given object is a rejected promise
-
whether the given object is a rejected promise
- Parameters
-
- obj the tested object
-
whether the given object is a resolved promise
- Parameters
-
- obj the tested object
-
isResolved () view sourcewhether the given object is a resolved promise if it is resolved with another promise, then that promise needs to be resolved as well.
-
then (fulfilled, rejected) view sourceregister callbacks when this promise object is resolved
- Parameters
-
- fulfilled {Function(*)} called when resolved successfully,pass a resolved value to this function and return a value (could be promise object) for the new promise's resolved value.
- [ rejected ] {Function(*)} called when error occurs,pass error reason to this function and return a new reason for the new promise's error reason
- Returns
-
- {KISSY.Promise} a new promise object
-
register callbacks when obj as a promise is resolved or call fulfilled callback directly when obj is not a promise object
- Parameters
-
- obj {KISSY.Promise|*} a promise object or value of any type
- fulfilled {Function(*)} called when obj resolved successfully,pass a resolved value to this function and return a value (could be promise object) for the new promise's resolved value.
- [ rejected ] {Function(*)} called when error occurs in obj,pass error reason to this function and return a new reason for the new promise's error reason
- Returns
-
- {KISSY.Promise} a new promise object
- Example
-
-
function check(p){ S.Promise.when(p,function(v){ alert(v===1); }); } var defer=S.Defer(); defer.resolve(1); check(1); // => alert(true) check(defer.promise); //=> alert(true);
-
Classes
- Anim
- Anim.Easing
- Attribute
- Base
- Button
- ComboBox
- ComboBox.LocalDataSource
- ComboBox.RemoteDataSource
- Component
- Component.Container
- Component.Controller
- Component.Manager
- Component.Render
- Component.UIBase
- Component.UIBase.Align
- Component.UIBase.Box
- Component.UIBase.Close
- Component.UIBase.Constrain
- Component.UIBase.ContentBox
- Component.UIBase.Drag
- Component.UIBase.Loading
- Component.UIBase.Mask
- Component.UIBase.Position
- Component.UIBase.Resize
- Component.UIBase.StdMod
- Cookie
- DataLazyload
- DD
- DD.Constrain
- DD.DDM
- DD.Draggable
- DD.DraggableDelegate
- DD.Droppable
- DD.DroppableDelegate
- DD.Proxy
- DD.Scroll
- DOM
- Editor
- Editor.Range
- Editor.Utils
- Editor.Walker
- Event
- Event.Object
- Event.Target
- IO
- IO.XhrObject
- KISSY
- KISSY.Defer
- KISSY.Loader
- KISSY.Loader.Module
- KISSY.Loader.Package
- KISSY.Promise
- Menu
- Menu.FilterMenu
- Menu.Item
- Menu.PopupMenu
- Menu.Separator
- MenuButton
- MenuButton.Option
- MenuButton.Select
- MVC
- MVC.Collection
- MVC.Model
- MVC.Router
- MVC.View
- NodeList
- Overlay
- Overlay.Dialog
- Overlay.Popup
- Resizable
- Tree
- Tree.CheckNode
- Tree.CheckTree
- Tree.Node
- Waterfall
- Waterfall.Loader