[TIMOB-20567] Hyperloop: Allow class usage with only the framework being required
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | High |
Status | Closed |
Resolution | Won't Fix |
Resolution Date | 2018-04-19T10:45:30.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Hyperloop, iOS |
Labels | frameworks, hyperloop, ios |
Reporter | Hans Knöchel |
Assignee | Unknown |
Created | 2016-03-15T12:49:12.000+0000 |
Updated | 2018-08-02T22:20:02.000+0000 |
Description
Currently, when we want to use a
UILabel
with Hyperloop, we need to require it the following way:
*iOS*:
var UILabel = require("UIKit/UILabel");
Now if we want to use another class from the UIKit
framework e.g. UIView
, we need to do:
var UIView = require("UIKit/UIView");
The approach is to make it possible to require frameworks like we do it in Swift/Objective-C and expose the available classes automatically:
require("UIKit"); // Can we do this require-statement anonymously?
var view = new UIView();
var label = new UILabel();
In addition, Alloy does a similar kind of pre-processing to expose variables like OS_IOS
and arguments
in new controllers.
/cc [~penrique] & [~jhaynie]
Something else to consider: What about ES6 module import syntax?
[~cwilliams] +1, we focus ES6 for 6.0.0. Would need to shift the issue then. Discussions welcome.
I just thought of wildcard patterns like
in Android, but that's not good practice right? Are there API's where package wildcards would make access?
It's fairly standard practice to use wildcards in java package imports. Most IDEs/tooling automatically expand it out the the actual types you use, so that the wildcard isn't used - probably just to be more specific/improve performance. So I think it would make sense to do an ES6 style import with a wildcard:
for ES5 syntax? I guess we'd have to have the require return an object with type names as keys inside it:
BTW, I'd suggest that this ticket be cloned out for the android implementation vs iOS implementation.
You are right, that are two different cases. Do we want to put this in 5.4.0 already or 6.0.0?
Resolving as
Won't Fix
since we have ES6 support in Hyperloop 3.1.0 and later already, which can be used for module based import of native frameworks, classes and enums.Closing old "Won't fix" tickets. If you disagree, please reopen.