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: 
tim_beynart
Channel Surfer

Best practice for targeting firmware, want to use <function> interface

Hello all,
I am working on a SceneGraph library that will be used in several apps to provide CMS, entitlement, advertising, and metrics to channel developers. This is a port from SDK1 to SG.
I am using to the <function> interface to expose my API. 
Is there any reason not to design an app this way? I see that <function> requires firmware 7.5, is it a bad idea to require a recent firmware version when our apps are intended for as wide an audience as possible?

For some background, these functions do not have return values, mostly they trigger Task nodes hidden away in my library. I am relying on the field observer model to provide responses for any function calls.
I like the idea of functions because they are familiar to developers coming from any other language that isn't Roku SceneGraph, and therefore they don't have to use the arcane Task 'control' field API to trigger my library's HTTP calls and the like.

For example, with the function node in play:

sub someFunction()
    genius_library = m.top.findNode("my_genius_library")
    genius_library.observeField("config_data","OnConfigLoaded")
    params={
        key:"hamsandwich"
        secret:"1234zyx"
        environment:"production"
    }
    genius_library.callFunc("loadConfiguration", params)
end sub

sub OnConfigLoaded(obj)
    ? "OnConfigLoaded"
end sub


If I don't take advantage of the <function> in order to target older firmware, thens devs are required to jump through more hoops to do the same thing:
sub someFunction()
    genius_library = m.top.findNode("my_genius_library") 
    config_loader = m.genius_library.findNode("config_loader")
    config_loader.observeField("config_data","OnConfigLoaded")
   config_loader.key="hamsandwich"
   config_loader.secret="1234zyx"
   config_loader.environment="production"
   config_loader.control = "RUN"
end sub

sub OnConfigLoaded(obj)
    ? "OnConfigLoaded"
end sub
0 Kudos