[TIMOB-25890] Windows: Support Hyperloop ES6
GitHub Issue | n/a |
---|---|
Type | New Feature |
Priority | High |
Status | Closed |
Resolution | Fixed |
Resolution Date | 2018-03-28T18:45:41.000+0000 |
Affected Version/s | Hyperloop 3.0.3 |
Fix Version/s | Hyperloop 3.1.0 |
Components | Windows |
Labels | hyperloop |
Reporter | Kota Iguchi |
Assignee | Kota Iguchi |
Created | 2018-03-21T02:04:04.000+0000 |
Updated | 2019-05-09T06:51:19.000+0000 |
Description
ES6
import
doesn't work for Hyperloop Windows because Hyperloop scans require
and generates glue code _before transpile (import
to require
) runs_ at compile time.
// ES5-style require call
var Int32 = require('System.Int32');
// ES6-style import
import Button from 'Windows.UI.Xaml.Controls.Button';
import PropertyValue from 'Windows.Foundation.PropertyValue';
import MessageDialog from 'Windows.UI.Popups.MessageDialog';
import UICommand from 'Windows.UI.Popups.UICommand';
let win = Ti.UI.createWindow({ backgroundColor: 'green' }),
button = new Button();
button.Content = "PUSH";
button.addEventListener('Tapped', () => {
const dialog = new MessageDialog('My Message');
dialog.Title = 'My Title';
dialog.DefaultCommandIndex = 0;
dialog.Commands.Add(new UICommand('OK', null, PropertyValue.CreateInt32(0)));
dialog.Commands.Add(new UICommand('Cancel', null, PropertyValue.CreateInt32(1)));
dialog.ShowAsync().then(function (command) {
const id = Int32.cast(command.Id);
alert((id == 0) ? 'Pushed "OK"' : 'Pushed "Cancel"')
});
});
win.add(button);
win.open();
FYI iOS and Android implementation: https://github.com/appcelerator/hyperloop.next/pull/270/files#diff-a84517cf68c2abfa4471206ee4d96147R242
https://github.com/appcelerator/hyperloop.next/pull/279