1
0
Fork 0

Renaming the "Component" interface to "Updatable". "Component" is just too generic and inspecific to be used as a public interface.

Also, making sure the looper is disabled when destruction is requested.
This commit is contained in:
Anton Gomez Alvedro 2014-11-30 10:46:26 +01:00
parent f92a2217de
commit 4edcf7c7a0
2 changed files with 11 additions and 10 deletions

View file

@ -35,7 +35,7 @@ var sqr = func(x) {x * x}
var InstrumentComponent = { var InstrumentComponent = {
parents: [Component], parents: [Updatable],
output: 0, output: 0,
reset: func { me.output = 0 }, reset: func { me.output = 0 },
}; };

View file

@ -17,21 +17,21 @@
# along with this program; if not, write to the Free Software # along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# Component # Updatable
# #
# The update loop accepts a vector of Components that it will update at regular # The update loop accepts a vector of Updatable elements that it will update at
# intervals. In order to make custom components, you should add Component to # regular intervals. In order to make custom elements, you should add Updatable
# the parents vector of your object: # to the parents vector of your object:
# #
# var CustomComponent = { # var MyElement = {
# parents: [Component], # parents: [Updatable],
# ... # ...
# }; # };
# #
# Your component shall then implement an "update" and a "reset" methods that # Your component shall then implement an "update" and "reset" methods that
# the UpdateLoop will call when needed. # the UpdateLoop will call when needed.
var Component = { var Updatable = {
reset: func { }, reset: func { },
update: func(dt) { }, update: func(dt) { },
}; };
@ -55,7 +55,7 @@ var update_prop = func(property) {
}; };
# UpdateLoop # UpdateLoop
# Wraps a set of components and updates them periodically. # Wraps a set of user provided objects and updates them periodically.
# Takes care of critical sim signals (reinit, fdm-initialized, speed-up). # Takes care of critical sim signals (reinit, fdm-initialized, speed-up).
var UpdateLoop = { var UpdateLoop = {
@ -99,6 +99,7 @@ var UpdateLoop = {
}, },
del: func { del: func {
me.disable();
foreach (var l; me.lst) removelistener(l); foreach (var l; me.lst) removelistener(l);
}, },