Although the docs generally illustrate one callback function, it’s not required to configure it that way. You can declare various callbacks to handle different aspects of the store functionality.
Well, the callback that you use for store.init() generally handles many things, but some store calls can have their own callback, i.e. .loadProducts(). Is there a specific reason why you want to separate this process out into many callbacks?
For handling transaction requests, you are going to use the call back listener function you defined in .init(). You can use techniques where you have the function you want to actually handle the call be part of your scene and attach it to the storyboard object directly:
… somewhere in your storyboard scene …
storyboard.state = {} -- if you haven't already done this. function storyboard.state.handlePurchase( params ) ... end
Since you’re including storyboard in main.lua where your store.init() is, then in that transaction call back function would would call:
[lua]
storyboard.state.handlePurchase( whatever, params, need, passed )
That way you won’t run into namespace issues with storyboard. The reason I used the “state” table was in a previous tutorial we showed people how to use that table to pass globally visible items around, and we’ve avoided using .state as a member for our use. Now that storyboard is deprecated, you can use anything that won’t clash with an existing API call. But if you switch to Composer or some other method, we can’t guarantee that “.state” is safe. By using the globally available table in that tutorial you future proof your code and get the same benefits.
Although the docs generally illustrate one callback function, it’s not required to configure it that way. You can declare various callbacks to handle different aspects of the store functionality.
Well, the callback that you use for store.init() generally handles many things, but some store calls can have their own callback, i.e. .loadProducts(). Is there a specific reason why you want to separate this process out into many callbacks?
For handling transaction requests, you are going to use the call back listener function you defined in .init(). You can use techniques where you have the function you want to actually handle the call be part of your scene and attach it to the storyboard object directly:
… somewhere in your storyboard scene …
storyboard.state = {} -- if you haven't already done this. function storyboard.state.handlePurchase( params ) ... end
Since you’re including storyboard in main.lua where your store.init() is, then in that transaction call back function would would call:
[lua]
storyboard.state.handlePurchase( whatever, params, need, passed )
That way you won’t run into namespace issues with storyboard. The reason I used the “state” table was in a previous tutorial we showed people how to use that table to pass globally visible items around, and we’ve avoided using .state as a member for our use. Now that storyboard is deprecated, you can use anything that won’t clash with an existing API call. But if you switch to Composer or some other method, we can’t guarantee that “.state” is safe. By using the globally available table in that tutorial you future proof your code and get the same benefits.