Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
nickchavez
Binge Watcher

Difference between observeField and observeFieldScoped ?

Jump to solution

Hi all,

I'm looking for clarification on what the difference is between observeField and observeFieldScoped on ifSGNodeField. The documentation (https://developer.roku.com/en-gb/docs/references/brightscript/interfaces/ifsgnodefield.md#observefie...) doesn't seem to describe the difference, as the callback for both is expected to be in the receiving component. In my testing, they both worked like this, seemingly identically. Does anyone know?

1 Solution

Accepted Solutions
sanity-check
Roku Guru

Re: Difference between observeField and observeFieldScoped ?

Jump to solution

As far as I understand it, the difference is when we come to unobserve.

If we observeFieldScoped then unobserveFieldScoped we won't remove other observers (i.e. from another component) - but if we observeField then unobserveField we'll clear out every other observer too.

I tend to use the 'scoped' versions everywhere.

Watching this thread in case I'm wrong, that'd be good to know!

View solution in original post

1 REPLY 1
sanity-check
Roku Guru

Re: Difference between observeField and observeFieldScoped ?

Jump to solution

As far as I understand it, the difference is when we come to unobserve.

If we observeFieldScoped then unobserveFieldScoped we won't remove other observers (i.e. from another component) - but if we observeField then unobserveField we'll clear out every other observer too.

I tend to use the 'scoped' versions everywhere.

Watching this thread in case I'm wrong, that'd be good to know!