destruk
9 years agoStreaming Star
ObserveField
If you have m.routine=m.top.findnode("routinename")
and you set m.routine.observefield("fieldname","callbackfunction")
- each time you execute the routine.observefield line it will add another callback every time the field changes.
This makes it really easy to string a bunch of small routines together to act on the change, however, it isn't smart enough to check the callback function name to see if it's the same as one already in the observefield callback queue. So it can end up calling the same function multiple times on subsequent calls. (for what it is worth)
So be sure to set unobservefield when the callback fires to prevent this. I ran into this issue observing the "content" field of a urltransfer request. Each time it ran, it added another callback because I didn't unobserve the field.
and you set m.routine.observefield("fieldname","callbackfunction")
- each time you execute the routine.observefield line it will add another callback every time the field changes.
This makes it really easy to string a bunch of small routines together to act on the change, however, it isn't smart enough to check the callback function name to see if it's the same as one already in the observefield callback queue. So it can end up calling the same function multiple times on subsequent calls. (for what it is worth)
So be sure to set unobservefield when the callback fires to prevent this. I ran into this issue observing the "content" field of a urltransfer request. Each time it ran, it added another callback because I didn't unobserve the field.