I asked about the difference between controller and helper and it prompted me to ask another, more specific set of questions:
- What is the best way to reuse JavaScript code across Lightning Components?
- What is the best way to test JavaScript code within Lightning Components?
- Do Lightning JavaScript files (Controller, Helper, Renderer, etc) have corresponding metadata components? I would like to pull this down via IDE for version control.
My main doubts around the platform revolve around how it fits in with our best practices of unit testing and code review, so answers to these questions could go a long way towards helping me cement it or eliminate it as an option. Thanks!
Best Answer
1. Reuseability
Helper.js is a good thing to share code within a bundle - but not across many bundles. I think a strong library concept is still missing. Actually it's not possible to use CDN due to CSP but they are planning to introduce whitelists. It even looks like whitelists could be already possible:
You can use Static Resources to provide libraries (package- or org-wide).
2. Testing
since it's very js-centric you might use some JS testing frameworks - but I expect salesforce to deliver here somthing.
3. Metadata / IDEs
All the Lightning metadata is available via Tooling API:
Alternatively access via Metadata API is working, too.
As far as I know, Force.com IDE still missing Lightning support. I think they are still on v30 or v31
You might also try a plugin for sublime/Mavensmate.
And CodeFusion actually does support Lightning since last year - however by design still without local files ;-)
But you need this package for lightning support - both, metadata and tooling API (v32) is supported.
I always planned to write a version control integration, but probably before that happens I'm going to open source the project.
A really cool thing about Lightning is the speed for saving files. It's not like apex or visualforce which needs about 3 to 10 seconds to save. Try saving a Lightning file it usually takes 0.300 to 0.800 seconds. First time fun coding! Doug's team unleashed a turbo here.