mirror of
https://github.com/nasa/openmct.git
synced 2025-04-20 09:01:14 +00:00
[Timers] Simplify mutation calls
This commit is contained in:
parent
906646704e
commit
6e1a43130d
@ -58,16 +58,12 @@ define(
|
||||
var domainObject = this.domainObject,
|
||||
now = this.now;
|
||||
|
||||
function setTimerState(model) {
|
||||
function updateModel(model) {
|
||||
model.timerState = 'paused';
|
||||
}
|
||||
|
||||
function setPausedTime(model) {
|
||||
model.pausedTime = now();
|
||||
}
|
||||
|
||||
return domainObject.useCapability('mutation', setTimerState) &&
|
||||
domainObject.useCapability('mutation', setPausedTime);
|
||||
return domainObject.useCapability('mutation', updateModel);
|
||||
};
|
||||
|
||||
return PauseTimerAction;
|
||||
|
@ -56,21 +56,13 @@ define(
|
||||
var domainObject = this.domainObject,
|
||||
now = this.now;
|
||||
|
||||
function setTimestamp(model) {
|
||||
function updateModel(model) {
|
||||
model.timestamp = now();
|
||||
}
|
||||
|
||||
function setTimerState(model) {
|
||||
model.timerState = 'started';
|
||||
}
|
||||
|
||||
function setPausedTime(model) {
|
||||
model.pausedTime = undefined;
|
||||
}
|
||||
|
||||
return domainObject.useCapability('mutation', setTimestamp) &&
|
||||
domainObject.useCapability('mutation', setTimerState) &&
|
||||
domainObject.useCapability('mutation', setPausedTime);
|
||||
return domainObject.useCapability('mutation', updateModel);
|
||||
};
|
||||
|
||||
return RestartTimerAction;
|
||||
|
@ -57,7 +57,7 @@ define(
|
||||
var domainObject = this.domainObject,
|
||||
now = this.now;
|
||||
|
||||
function setTimestamp(model) {
|
||||
function updateModel(model) {
|
||||
//if we are resuming
|
||||
if (model.pausedTime) {
|
||||
var timeShift = now() - model.pausedTime;
|
||||
@ -65,19 +65,11 @@ define(
|
||||
} else {
|
||||
model.timestamp = now();
|
||||
}
|
||||
}
|
||||
|
||||
function setTimerState(model) {
|
||||
model.timerState = 'started';
|
||||
}
|
||||
|
||||
function setPausedTime(model) {
|
||||
model.pausedTime = undefined;
|
||||
}
|
||||
|
||||
return domainObject.useCapability('mutation', setTimestamp) &&
|
||||
domainObject.useCapability('mutation', setTimerState) &&
|
||||
domainObject.useCapability('mutation', setPausedTime);
|
||||
return domainObject.useCapability('mutation', updateModel);
|
||||
};
|
||||
|
||||
return StartTimerAction;
|
||||
|
@ -57,21 +57,13 @@ define(
|
||||
StopTimerAction.prototype.perform = function () {
|
||||
var domainObject = this.domainObject;
|
||||
|
||||
function setTimestamp(model) {
|
||||
function updateModel(model) {
|
||||
model.timestamp = undefined;
|
||||
}
|
||||
|
||||
function setTimerState(model) {
|
||||
model.timerState = 'stopped';
|
||||
}
|
||||
|
||||
function setPausedTime(model) {
|
||||
model.pausedTime = undefined;
|
||||
}
|
||||
|
||||
return domainObject.useCapability('mutation', setTimestamp) &&
|
||||
domainObject.useCapability('mutation', setTimerState) &&
|
||||
domainObject.useCapability('mutation', setPausedTime);
|
||||
return domainObject.useCapability('mutation', updateModel);
|
||||
};
|
||||
|
||||
return StopTimerAction;
|
||||
|
Loading…
x
Reference in New Issue
Block a user