Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-25890] Windows: Support Hyperloop ES6

GitHub Issuen/a
TypeNew Feature
PriorityHigh
StatusClosed
ResolutionFixed
Resolution Date2018-03-28T18:45:41.000+0000
Affected Version/sHyperloop 3.0.3
Fix Version/sHyperloop 3.1.0
ComponentsWindows
Labelshyperloop
ReporterKota Iguchi
AssigneeKota Iguchi
Created2018-03-21T02:04:04.000+0000
Updated2019-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();

Comments

  1. Kota Iguchi 2018-03-21

    FYI iOS and Android implementation: https://github.com/appcelerator/hyperloop.next/pull/270/files#diff-a84517cf68c2abfa4471206ee4d96147R242
  2. Kota Iguchi 2018-03-27

    https://github.com/appcelerator/hyperloop.next/pull/279

JSON Source