2015-03-20 10:56:11 -07:00
|
|
|
/*global define*/
|
|
|
|
|
|
|
|
define(
|
2015-03-20 13:06:49 -07:00
|
|
|
[
|
|
|
|
'./PersistenceQueueImpl',
|
|
|
|
'./PersistenceQueueHandler',
|
|
|
|
'./PersistenceFailureHandler'
|
|
|
|
],
|
|
|
|
function (
|
|
|
|
PersistenceQueueImpl,
|
|
|
|
PersistenceQueueHandler,
|
|
|
|
PersistenceFailureHandler
|
|
|
|
) {
|
2015-03-20 10:56:11 -07:00
|
|
|
"use strict";
|
|
|
|
|
2015-03-20 13:06:49 -07:00
|
|
|
|
2015-03-20 10:56:11 -07:00
|
|
|
/**
|
|
|
|
* The PersistenceQueue is used by the QueuingPersistenceCapability
|
|
|
|
* to aggregrate calls for object persistence. These are then issued
|
|
|
|
* in a group, such that if some or all are rejected, this result can
|
|
|
|
* be shown to the user (again, in a group.)
|
|
|
|
*
|
2015-03-20 13:06:49 -07:00
|
|
|
* This constructor is exposed as a service, but handles only the
|
|
|
|
* wiring of injected dependencies; behavior is implemented in the
|
|
|
|
* various component parts.
|
|
|
|
*
|
2015-03-20 10:56:11 -07:00
|
|
|
* @param $timeout Angular's $timeout
|
2015-03-20 13:06:49 -07:00
|
|
|
* @param {PersistenceQueueHandler} handler handles actual
|
|
|
|
* persistence when the queue is flushed
|
2015-03-20 10:56:11 -07:00
|
|
|
* @param {number} [DELAY] optional; delay in milliseconds between
|
|
|
|
* attempts to flush the queue
|
|
|
|
*/
|
2015-03-20 13:06:49 -07:00
|
|
|
function PersistenceQueue(
|
|
|
|
$q,
|
|
|
|
$timeout,
|
|
|
|
dialogService,
|
|
|
|
persistenceService,
|
|
|
|
PERSISTENCE_QUEUE_DELAY
|
|
|
|
) {
|
|
|
|
// Wire up injected dependencies
|
|
|
|
return new PersistenceQueueImpl(
|
|
|
|
$timeout,
|
|
|
|
new PersistenceQueueHandler(
|
|
|
|
$q,
|
|
|
|
new PersistenceFailureHandler(
|
|
|
|
$q,
|
|
|
|
dialogService,
|
|
|
|
persistenceService
|
|
|
|
)
|
|
|
|
),
|
|
|
|
PERSISTENCE_QUEUE_DELAY
|
|
|
|
);
|
2015-03-20 10:56:11 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
return PersistenceQueue;
|
|
|
|
}
|
|
|
|
);
|