From 1ce8a2afd8a2e3ae7081832bd8eafaa82a478051 Mon Sep 17 00:00:00 2001 From: Nathan Walker Date: Fri, 13 May 2016 09:01:56 -0700 Subject: [PATCH] chore: update angular rc.1, also improve setup --- .gitignore | 1 + index.html | 34 +++++++++++++++++++++++++++--- package.json | 22 ++++++++++++++----- src/app/app.html | 6 +++--- src/app/app.ts | 6 +++--- src/app/subscription.html | 6 +++--- src/app/subscription.ts | 24 ++++++++++++--------- src/tsconfig.json => tsconfig.json | 7 +++++- typings.json | 15 +++++++++++++ 9 files changed, 93 insertions(+), 28 deletions(-) rename src/tsconfig.json => tsconfig.json (70%) create mode 100644 typings.json diff --git a/.gitignore b/.gitignore index 5b78e86..e909611 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ src/app/*.js src/app/*.js.map node_modules +typings diff --git a/index.html b/index.html index 2fcb18f..d7ce7df 100644 --- a/index.html +++ b/index.html @@ -6,14 +6,42 @@ - + + + + + + + + + + diff --git a/package.json b/package.json index c089038..712e7df 100644 --- a/package.json +++ b/package.json @@ -4,18 +4,30 @@ "description": "", "main": "index.js", "scripts": { - "tsc": "tsc -p src -w", - "start": "live-server --open=src" + "tsc": "tsc", + "start": "npm run tsc && live-server --open=/", + "postinstall": "typings install" }, "keywords": [], "author": "", "license": "ISC", "dependencies": { - "angular2": "2.0.0-alpha.47", - "systemjs": "0.19.2" + "@angular/common": "2.0.0-rc.1", + "@angular/compiler": "2.0.0-rc.1", + "@angular/core": "2.0.0-rc.1", + "@angular/http": "2.0.0-rc.1", + "@angular/platform-browser": "2.0.0-rc.1", + "@angular/platform-browser-dynamic": "2.0.0-rc.1", + "@angular/router": "2.0.0-rc.1", + "es6-shim": "0.35.0", + "reflect-metadata": "0.1.2", + "rxjs": "5.0.0-beta.6", + "systemjs": "0.19.26", + "zone.js": "^0.6.12" }, "devDependencies": { "live-server": "^0.8.2", - "typescript": "^1.6.2" + "typescript": "^1.6.2", + "typings": "^0.8.1" } } diff --git a/src/app/app.html b/src/app/app.html index 8bd1580..4fb9916 100644 --- a/src/app/app.html +++ b/src/app/app.html @@ -10,8 +10,8 @@

-
- + +
@@ -21,7 +21,7 @@

-
+

Tweets for {{ channel.term }} diff --git a/src/app/app.ts b/src/app/app.ts index c0cfffa..ea527c5 100644 --- a/src/app/app.ts +++ b/src/app/app.ts @@ -1,10 +1,10 @@ declare var Pusher: any; +import {bootstrap} from '@angular/platform-browser-dynamic'; import { Component, - Attribute, - bootstrap -} from 'angular2/angular2'; + Attribute +} from '@angular/core'; import SubscriptionComponent from './subscription'; diff --git a/src/app/subscription.html b/src/app/subscription.html index 1056b8d..59d0371 100644 --- a/src/app/subscription.html +++ b/src/app/subscription.html @@ -1,5 +1,5 @@ -
    -
  • -

    {{ result.tweet.text }}

    +
      +
    • +

    diff --git a/src/app/subscription.ts b/src/app/subscription.ts index 6c1121d..0993c1d 100644 --- a/src/app/subscription.ts +++ b/src/app/subscription.ts @@ -1,23 +1,27 @@ import { Component, - Input -} from 'angular2/angular2'; + Input, + AfterViewChecked, + OnInit, + OnDestroy +} from '@angular/core'; @Component({ selector: 'subscription', - templateUrl: 'src/app/subscription.html', - inputs: ['search', 'pusher'] + templateUrl: 'src/app/subscription.html' }) -export default class SubscriptionComponent { +export default class SubscriptionComponent implements OnInit, OnDestroy, AfterViewChecked { @Input() search: any; @Input() pusher; public tweets : Object[]; private channel; private subscribed: boolean = false; + private className: String; - private ngOnInit() { + public ngOnInit() { this.subscribeToChannel(); this.tweets = []; + this.className = this.search.term.replace(' ', '-'); } private subscribeToChannel() { @@ -35,7 +39,7 @@ export default class SubscriptionComponent { // TODO: bring back when working correctly (see bottom of ngAfterViewChecked) // This should fire anytime bindings are modified from AppComponent but it's not // Don't have time to debug at moment, but fix if you can :) - // private ngOnChanges() { + // public ngOnChanges() { // console.log(this.search); // if (!this.search.active && this.subscribed) { // this.ngOnDestroy(); @@ -44,14 +48,14 @@ export default class SubscriptionComponent { // } // } - private ngOnDestroy() { + public ngOnDestroy() { this.pusher.unsubscribe(btoa(this.search.term)); this.channel && this.channel.unbind(); this.subscribed = false; } - private ngAfterViewChecked() { - var listItem = document.querySelector(".channel-" + this.search.term); + public ngAfterViewChecked() { + var listItem = document.querySelector(".channel-" + this.className); if (listItem) { listItem.scrollTop = listItem.scrollHeight; } diff --git a/src/tsconfig.json b/tsconfig.json similarity index 70% rename from src/tsconfig.json rename to tsconfig.json index 7e4317c..0e1150e 100644 --- a/src/tsconfig.json +++ b/tsconfig.json @@ -7,5 +7,10 @@ "experimentalDecorators": true, "removeComments": false, "noImplicitAny": false - } + }, + "exclude": [ + "node_modules", + "typings/browser.d.ts", + "typings/browser" + ] } diff --git a/typings.json b/typings.json new file mode 100644 index 0000000..4968be1 --- /dev/null +++ b/typings.json @@ -0,0 +1,15 @@ +{ + "dependencies": { + "xhr2": "github:gdi2290/typed-xhr2#69f2b8d40d0cd407c1b2a2f2f41fecc6852cabbb" + }, + "devDependencies": {}, + "ambientDependencies": { + "async": "github:DefinitelyTyped/DefinitelyTyped/async/async.d.ts#5c3e47967affa3c4128a3875d1664ba206ae1b0f", + "es6-shim": "github:DefinitelyTyped/DefinitelyTyped/es6-shim/es6-shim.d.ts#6697d6f7dadbf5773cb40ecda35a76027e0783b2", + "jasmine": "github:DefinitelyTyped/DefinitelyTyped/jasmine/jasmine.d.ts#26c98c8a9530c44f8c801ccc3b2057e2101187ee", + "ng2": "github:gdi2290/typings-ng2/ng2.d.ts#32998ff5584c0eab0cd9dc7704abb1c5c450701c", + "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#138ad74b9e8e6c08af7633964962835add4c91e2", + "systemjs": "github:DefinitelyTyped/DefinitelyTyped/systemjs/systemjs.d.ts#5c3e47967affa3c4128a3875d1664ba206ae1b0f", + "zone.js": "github:DefinitelyTyped/DefinitelyTyped/zone.js/zone.js.d.ts#b923a5aaf013ac84c566f27ba6b5843211981c7a" + } +}