mirror of
https://github.com/nasa/openmct.git
synced 2025-04-08 20:04:27 +00:00
[Core] Accelerate promises during mutation
Use a fast-promise approach (instead of ) when handling mutation of domain objects, to ensure that mutation resolves during the current tick. Needed for drag interactions of WTD-931.
This commit is contained in:
parent
b05315a140
commit
00daa32f56
@ -21,6 +21,16 @@ define(
|
||||
});
|
||||
}
|
||||
|
||||
// Utility function to cast to a promise, without waiting
|
||||
// for nextTick if a value is non-promise-like.
|
||||
function fastPromise(value) {
|
||||
return (value || {}).then ? value : {
|
||||
then: function (callback) {
|
||||
return fastPromise(callback(value));
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* The `mutation` capability allows a domain object's model to be
|
||||
* modified. Wrapping such modifications in calls made through
|
||||
@ -73,8 +83,7 @@ define(
|
||||
|
||||
// Invoke the provided mutator, then make changes to
|
||||
// the underlying model (if applicable.)
|
||||
return $q.when(mutator(clone))
|
||||
.then(handleMutation);
|
||||
return fastPromise(mutator(clone)).then(handleMutation);
|
||||
}
|
||||
|
||||
return {
|
||||
|
Loading…
x
Reference in New Issue
Block a user