- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ObserveField triggered by its callback doesn't trigger observer
Observing a case where observefield does not work. Consider the following code:
sub Main() m.count = 0 c = createObject("roSGNode", "ContentNode") c.title = "" c.observeFieldScoped("title", "onTitleChanged") c.title = "old title" end sub sub onTitleChanged(event) m.count++ ? "count: " m.count c = event.getRoSGNode() c.title = "new title" end subIs there a technical reason why onTitleChanged only triggers once? Specifically when setting "old title"? I would have expected setting "new title" to also trigger the callback, but that is not the case. I couldn't find anything in the documentation, but considered there could be a limitation with callbacks triggering their own observers. Any ideas?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: ObserveField triggered by its callback doesn't trigger observer
I just tried an experiment and I see the same thing as you. If you want to see something even stranger try setting two observers - one with a function callback and one with a port. What I see is the function callback triggering on the initial change, but the message queue only sees the change made in the function callback. I'd expect the message queue to get two messages.
Scene graph, and Brightscript in general, are not documented very well, if at all, as to what's happening under the hood. Before @EnTerr became @NB_ this was exactly the kind of thing he would be obsessed about, but it appears that once you become a Roku employee you're discouraged, if not forbidden, to post here, so don't expect any answers from Roku. I've found it's much easier to workaround issues like this than to try to get any information/help out of Roku.
Help others find this answer and click "Accept as Solution."
If you appreciate my answer, maybe give me a Kudo.
I am not a Roku employee.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Re: ObserveField triggered by its callback doesn't trigger observer
The technical reason may be avoidance of infinite loops, ie there should be no cycles in the observer call cascade