Top Banner
Real-World Windows 8 Apps in JavaScript
15

Real World Windows 8 Apps in JavaScript

Jan 15, 2015

Download

Technology

Let’s talk about what Microsoft has given us for building ambitious, real-world Windows 8 apps in HTML5 and JavaScript—but also what’s missing, and how we can fill in the gaps.
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Real World Windows 8 Apps in JavaScript

Real-World Windows 8 Apps in JavaScript

Page 2: Real World Windows 8 Apps in JavaScript

Domenic Denicola

• https://github.com/domenic

• https://npmjs.org/~domenic

• https://github.com/NobleJS

Things I’ve done recently:

• http://es6isnigh.com

• Promises/A+

Page 3: Real World Windows 8 Apps in JavaScript

NOOK Study 2.1http://www.barnesandnoble.com/nookstudy170K+ LOC

Page 4: Real World Windows 8 Apps in JavaScript

The Advanced BasicsIMPORTANT STUFF THAT’S NOT OBVIOUS

Page 5: Real World Windows 8 Apps in JavaScript

Windows vs. WinJSWindows: shared between all app types

Mostly non-applicable stuff: Xaml, JSON, threading, …

Gems you might have to deal with:• Windows.Graphics.Display.DisplayProperties.resolutionScale• Windows.UI.Notifications.ToastNotificationManager.createToastNotifier• Windows.Globalization.DateTimeFormatting.DateTimeFormatter.shortDa

te.format

Useful-looking namespaces:• Windows.Devices.Sensors, Windows.Storage.Pickers,

Windows.Networking.PushNotifications, …

Page 6: Real World Windows 8 Apps in JavaScript

Windows vs. WinJSWinJS: JavaScript specific

Good/useful:• WinJS.Application: application lifecycle• WinJS.Resources: resource strings• WinJS.UI: controls

Bad/ugly:• WinJS.Utilities, WinJS.Fragments, WinJS.Navigation, WinJS.UI.Pages: use

other libs• WinJS.Class, WinJS.Namespace: yet another class library• WinJS.Binding: one-way databinding, WTF!

Page 7: Real World Windows 8 Apps in JavaScript

Let’s talk about those controls<div data-win-control="WinJS.UI.AppBar"> <button data-win-control="WinJS.UI.AppBarCommand" data-win-options="{ id: 'cmd', label: 'Command', icon: 'placeholder' }"> </button></div>Inert until WinJS.UI.processAll is called:

• Then they morph into fully-functioning controls

• In particular the element gets a winControl property

Page 8: Real World Windows 8 Apps in JavaScript

Let’s talk about those controlsThe good news:

• Implemented entirely in JavaScript, HTML, and CSS!

• Takes care of so much for you

• You can avoid the inline attributes (which can only refer to global variables) by using WinJS.UI.setOptions(element) after calling WinJS.UI.processAll(element).

Page 9: Real World Windows 8 Apps in JavaScript

Let’s talk about those controlsThe bad news:

Page 10: Real World Windows 8 Apps in JavaScript

Demo time

Page 11: Real World Windows 8 Apps in JavaScript

Cooking with GasWHAT REAL APPS NEED THAT STUPID DEMO APPS DON’T

Page 12: Real World Windows 8 Apps in JavaScript

It’s 2012. What do we expect?• A module system

• A package ecosystem

• A way to stop writing raw CSS/HTML/JS

• A build process!

Introducing: WinningJS-build

Page 13: Real World Windows 8 Apps in JavaScript

It’s 2012. How do we structure apps?• We use a MV* framework:

• Angular• Backbone• Ember• Knockout• …

• BUT! We need to integrate with WinJS controls• This needs custom solutions• WinningJS UI is one, but it’s immature and based on Knockout.• Come up with your own!

• Ditch the WinJS navigation/pages/fragments. We know how to solve these problems.

Page 14: Real World Windows 8 Apps in JavaScript

It’s 2012. How do we write code?

First, we write tests.

Too bad there’s no support for running them, at all.

This problem is not solved yet. Ideas:

• Stub everything, including the DOM/WinJS.*/Windows.*, and run your tests in Node.

• Create a “hidden screen” where you can manually run your tests.

• Automate somehow.

Page 15: Real World Windows 8 Apps in JavaScript

What’s Next

• We need more open-source efforts:• Libraries to wrap overcomplicated

WinJS/Windows• Integration into other MV* frameworks• Sample apps

• We need tooling:• Better scaffolding and build tools• Improve and extend Visual Studio…• … or branch out and make it work in a text

editor

• We need to solve the testing problem!

Talk to me. Let’s build something.