I just had the chance to try and my observer is not working. Or at least what I'm finding is that it's not being dispatched because 'm.global.usertype' isn't actually changing.
The code looks to be getting executed, however, when I output the 'm.global' SG Node afterward, I receive the following:
<Component: roSGNode> =
{
change: <Component: roAssociativeArray>
focusable: false
focusedChild: <Component: roInvalid>
id: "GlobalNode"
usertype: "Preview"
}
The 'usertype' property is there, but still contains the value it was initialized at, which tells me there is something wrong with how I'm attempting to set the value in my else block.
I can comment up my code to hopefully give you a better idea of what I'm trying to achieve:
SubscribeScreen.brs
if (m.global = invalid)
' This block executes when the user opens the screen for the first time
m.global = screen.getGlobalNode()
m.global.id = "GlobalNode"
m.global.addFields( {userType: "Preview"} ) ' This line adds "userType": "Preview" to the m.global roSGNode
else
' on subsequent opens, 'm.global' has been initialized, so we just want to update its 'userType' value which could have changed
m.global.userType = "Monthly"
end if
RowListScene.brs
function init()
m.top.backgroundURI = "pkg:/images/background.png"
m.top.backExitsScene = true
m.global.observeField("userType", "userTypeChanged") ' setting up my observer in the init() function
...
end function
' defining my observer handler
function userTypeChanged()
' but I never see this called, most likely because I have never seen the value update
print "USER TYPE HAS CHANGED"
m.userType = m.global.userType
end function