Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
groman00
Level 7

Observer callback functions

I'm seeing this on the 7.1 release notes:
Parameters can now be passed to observer callback functions (ifSGNodeField).
https://sdkdocs.roku.com/display/sdkdoc ... 04/05/2016

There's no mention of how to use parameters with observeField in the docs. Does anyone have an example?
https://sdkdocs.roku.com/display/sdkdoc/ifSGNodeField
Greg Roman
Senior Software Engineer, AOL Alpha
0 Kudos
3 REPLIES 3

Re: Observer callback functions

Hi Greg, it's possible to call an anonymous function that calls your function with parameters. Although it maybe be a bit troublesome it's just barely if it even is slower than calling it directly so it won't be noticeable at all. Please see the example below.

ObserveField("MyField", "AnonymousFunction")

Sub AnonymousFunction
MyFunction(MyField) <-- <Function that I want to call with parameters>
End Sub

Notice that I use MyField as just an example parameter. In this case MyField would be changed to the parameter that I want to set off the Observer. If you need more than one parameter passed these can be achieved through things like using the global variable, registry (not recommended), etc.
0 Kudos
EnTerr
Level 11

Re: Observer callback functions

Hi RokuChristianL - and welcome to the forum!

i don't think you understood the question, your answer does not relate to passing parameters to observer callback functions.
Of course inside a function one can call another function with arguments, that's not the point.
0 Kudos
EnTerr
Level 11

Re: Observer callback functions

@groman00 -
this was clarified a few days later by update in the doco page, see this diff for the changes - or just re-read "First Form" sub-section of ifSGNodeField.observeField()
0 Kudos