Added teardown styled use effect
This commit is contained in:
@ -10,6 +10,8 @@ namespace Dawn {
|
||||
class IStateProperty {
|
||||
public:
|
||||
std::vector<std::function<void()>> _effectListners;
|
||||
std::vector<std::function<std::function<void()>()>> _effectListnersWithTeardown;
|
||||
std::vector<std::function<void()>> _effectTeardowns;
|
||||
};
|
||||
|
||||
template<class V>
|
||||
@ -26,12 +28,28 @@ namespace Dawn {
|
||||
this->previous = this->_realValue;
|
||||
this->_realValue = val;
|
||||
|
||||
// Run the teardowns
|
||||
auto itTeardown = this->_effectTeardowns.begin();
|
||||
while(itTeardown != this->_effectTeardowns.end()) {
|
||||
(*itTeardown)();
|
||||
++itTeardown;
|
||||
}
|
||||
this->_effectTeardowns.clear();
|
||||
|
||||
// Notify the effect listeners
|
||||
auto itEffect = this->_effectListners.begin();
|
||||
while(itEffect != this->_effectListners.end()) {
|
||||
(*itEffect)();
|
||||
++itEffect;
|
||||
}
|
||||
|
||||
// Notify the teardown effect listeners
|
||||
auto itWithTeardown = this->_effectListnersWithTeardown.begin();
|
||||
while(itWithTeardown != this->_effectListnersWithTeardown.end()) {
|
||||
auto teardown = (*itWithTeardown)();
|
||||
this->_effectTeardowns.push_back(teardown);
|
||||
++itWithTeardown;
|
||||
}
|
||||
}
|
||||
|
||||
public:
|
||||
|
Reference in New Issue
Block a user