Book Image

Learning TypeScript

By : Remo H. Jansen
Book Image

Learning TypeScript

By: Remo H. Jansen

Overview of this book

<p>TypeScript is an open source and cross-platform typed superset of JavaScript that compiles to plain JavaScript that runs in any browser or any host. It allows developers to use the future versions of JavaScript (ECMAScript 6 and 7) today. TypeScript adds optional static types, classes, and modules to JavaScript, to enable great tooling and better structuring of large JavaScript applications.</p> <p>This book is a step-by-step guide that will get you started with TypeScript with the help of practical examples. You start off by understanding the basics of TypeScript. Next, automation tools like Grunt are explained followed by a detailed description of function, generics, callbacks and promises. After this, object-oriented features and the memory management functionality of TypeScript are explained. At the end of this book, you will have learned enough to implement all the concepts and build a single page application from scratch.</p>
Table of Contents (18 chapters)
Learning TypeScript
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Implementing the symbol view


Let's create a new file named symbol_view.ts under the app/views directory. The SymbolView view receives the stock data formatted by the QuoteModel model through the mediator using the app.view.symbol.render event:

/// <reference path="../../framework/interfaces"/>

import { View, AppEvent,ViewSettings } from "../../framework/framework";

@ViewSettings("./source/app/templates/symbol.hbs", "#outlet")
class SymbolView extends View implements IView {

  constructor(metiator : IMediator) {
    super(metiator);
  }

This view is just like MarketView; it subscribes to some events using the initialize method, and later disposes of those events using the dispose method. The SymbolView view can also initialize and dispose of user events using the bindDomEvents and unbindDomEvents methods.

However, there is one significant difference between SymbolView and MarketView. After the promise returned by renderAsync has been fulfilled and the user events have been initialized...