CREATE-article# #
[previously]
- [2017-08-25][00:00] NEW task IN ?
- ] # 7389 - CREATE-article# #
- [00:00] NEW article IN
- ] # # - jquery defferred - mastering the art of the promise
[currently]
- [] PASS -
- ]
- ] EXAMPLE
- []
- [] todo
- x] add create-article task, # 7389, this
- x] add reference to this task on index
- x] add reference to index on this task
- ]
- ] content - add reference to video tutorials ( get BM from saf)
- ] content - add notes from scrap
- ]
[next]
- ]
- ] entering the lovely world of asynch calllback handling with
- ] the OnSuccess callback being passed to so many
- ] var OnSuccess - defining the OnSuccess callback handler in your , EX on pg
[reference]
] Promises are a cleaner way of doing javascript callbacks
] better way of handling 'asynch' operations
] promise are part of the js standard in es6
] use 1 deferred object VS using multiple callbacks, ex ( OnSuccess, OnFailure, ...)
] promises have a 'status' property, the status can be either 'pending' or 'resolved'
] the status property is immutiable, aka it cannot be changed by other objects code, other then when the .
EXAMPLE - generic
return $.deferred => {
$.when( getSomething() )
.done( (something)
doSomething(something) )
}.promise();
EXAMPLE - specific - single object
return $.deferred => {
$.when ( getAvailableCar() )
.done((car) => {
car.availability = false;
// process EX = carsAvailable.push(car);
})
}.promise();