Reputation: 3213
Per the instructions here in order to use the Native API I need to add an 'Ext.require()' to the code. How do I do that in Sencha Architect 2? It seems like everything outside a custom function or an event is readonly so I can't just add my own code ad-hoc.
Upvotes: 2
Views: 3247
Reputation: 1642
The view (or the MVC applicable) that requires the code defines this requirement, so it is only called when it is needed.
Ext.define('MyApp.view.SomePageView', {
extend: 'Ext.Panel',
alias: 'widget.somepageview',
requires: [
'Ext.device.Camera', // requires go here!
'...'
]
For native requirements (things not a custom extension), check the right hand column on Sencha Docs. For this example, and for ST2.3.1, it can be located here. At the top, you can see Ext.device.Camera descends straight from Ext.Base and does not require Ext.device. At the bottom of that block of requirements being defined, there's the link for Camera.js. Opening that link, you can see exactly what is going on. By defining requires: ['Ext.device.Camera']
you are also automatically loading in all this requires to operate.
In Architect when you define a primary MVC or S, it is added to the Application Requires. So in Architect, I'll be able to see SomePageView listed under Application > Ext.app.Controller > views. During the build process this chain of requires down through the app will be included within the final package, whether using Architect's build, or a commandline call like sencha app build
using Sencha Cmd.
Upvotes: 0
Reputation: 321
As suggested by Bharat Nagwani, Architect now includes a way to require any classes that you would like to dynamically load.
Luca Candela and I presented a small application which illustrates use of the Ext.device.Camera API a few weeks ago in London. https://github.com/CaliLuke/NativeContacts
In order to include the device api in your application, do the following:
So to sum it up, make sure the files are there. Tell the application that you need that Class and then tell the loader where to find those files you've just put into your project folder.
Upvotes: 3
Reputation: 66
The next update in Architect provide requires as a property on Application node so you can add that there. For now just add the requires in your Application launch function since that is writable.
Upvotes: 2