[Timers] Simplify mutation calls
This commit is contained in:
@@ -58,16 +58,12 @@ define(
|
|||||||
var domainObject = this.domainObject,
|
var domainObject = this.domainObject,
|
||||||
now = this.now;
|
now = this.now;
|
||||||
|
|
||||||
function setTimerState(model) {
|
function updateModel(model) {
|
||||||
model.timerState = 'paused';
|
model.timerState = 'paused';
|
||||||
}
|
|
||||||
|
|
||||||
function setPausedTime(model) {
|
|
||||||
model.pausedTime = now();
|
model.pausedTime = now();
|
||||||
}
|
}
|
||||||
|
|
||||||
return domainObject.useCapability('mutation', setTimerState) &&
|
return domainObject.useCapability('mutation', updateModel);
|
||||||
domainObject.useCapability('mutation', setPausedTime);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return PauseTimerAction;
|
return PauseTimerAction;
|
||||||
|
|||||||
@@ -56,21 +56,13 @@ define(
|
|||||||
var domainObject = this.domainObject,
|
var domainObject = this.domainObject,
|
||||||
now = this.now;
|
now = this.now;
|
||||||
|
|
||||||
function setTimestamp(model) {
|
function updateModel(model) {
|
||||||
model.timestamp = now();
|
model.timestamp = now();
|
||||||
}
|
|
||||||
|
|
||||||
function setTimerState(model) {
|
|
||||||
model.timerState = 'started';
|
model.timerState = 'started';
|
||||||
}
|
|
||||||
|
|
||||||
function setPausedTime(model) {
|
|
||||||
model.pausedTime = undefined;
|
model.pausedTime = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return domainObject.useCapability('mutation', setTimestamp) &&
|
return domainObject.useCapability('mutation', updateModel);
|
||||||
domainObject.useCapability('mutation', setTimerState) &&
|
|
||||||
domainObject.useCapability('mutation', setPausedTime);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return RestartTimerAction;
|
return RestartTimerAction;
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ define(
|
|||||||
var domainObject = this.domainObject,
|
var domainObject = this.domainObject,
|
||||||
now = this.now;
|
now = this.now;
|
||||||
|
|
||||||
function setTimestamp(model) {
|
function updateModel(model) {
|
||||||
//if we are resuming
|
//if we are resuming
|
||||||
if (model.pausedTime) {
|
if (model.pausedTime) {
|
||||||
var timeShift = now() - model.pausedTime;
|
var timeShift = now() - model.pausedTime;
|
||||||
@@ -65,19 +65,11 @@ define(
|
|||||||
} else {
|
} else {
|
||||||
model.timestamp = now();
|
model.timestamp = now();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
function setTimerState(model) {
|
|
||||||
model.timerState = 'started';
|
model.timerState = 'started';
|
||||||
}
|
|
||||||
|
|
||||||
function setPausedTime(model) {
|
|
||||||
model.pausedTime = undefined;
|
model.pausedTime = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return domainObject.useCapability('mutation', setTimestamp) &&
|
return domainObject.useCapability('mutation', updateModel);
|
||||||
domainObject.useCapability('mutation', setTimerState) &&
|
|
||||||
domainObject.useCapability('mutation', setPausedTime);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return StartTimerAction;
|
return StartTimerAction;
|
||||||
|
|||||||
@@ -57,21 +57,13 @@ define(
|
|||||||
StopTimerAction.prototype.perform = function () {
|
StopTimerAction.prototype.perform = function () {
|
||||||
var domainObject = this.domainObject;
|
var domainObject = this.domainObject;
|
||||||
|
|
||||||
function setTimestamp(model) {
|
function updateModel(model) {
|
||||||
model.timestamp = undefined;
|
model.timestamp = undefined;
|
||||||
}
|
|
||||||
|
|
||||||
function setTimerState(model) {
|
|
||||||
model.timerState = 'stopped';
|
model.timerState = 'stopped';
|
||||||
}
|
|
||||||
|
|
||||||
function setPausedTime(model) {
|
|
||||||
model.pausedTime = undefined;
|
model.pausedTime = undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
return domainObject.useCapability('mutation', setTimestamp) &&
|
return domainObject.useCapability('mutation', updateModel);
|
||||||
domainObject.useCapability('mutation', setTimerState) &&
|
|
||||||
domainObject.useCapability('mutation', setPausedTime);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
return StopTimerAction;
|
return StopTimerAction;
|
||||||
|
|||||||
Reference in New Issue
Block a user