Skip to content
This repository was archived by the owner on Feb 26, 2024. It is now read-only.

Commit 6e5a77d

Browse files
authored
chore(deps): update Angular2 to rc.6 and @angular/router to 3.0.0-rc.2' (#84)
1 parent ea48441 commit 6e5a77d

34 files changed

+943
-457
lines changed

README.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ iOS:
3030
* OR, `gulp watch` and open `.dist/app/ngReactNative/ios/ngReactNative.xcodeproj` in Xcode and hit `Run`
3131

3232
Tests:
33-
* `gulp test.node` to run tests in Node
3433
* `gulp test.browser` to run tests in Chrome
3534

3635
Doc:

doc/pages/bootstrap.jade

Lines changed: 14 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,21 @@ block content
99
To bootstrap an application, you must use the special method `bootstrapReactNative`.
1010

1111
```
12-
import {bootstrapReactNative}
13-
from 'angular2-react-native';
14-
import {Example} from "./example";
12+
import {bootstrapReactNative} from 'angular2-react-native';
13+
import {MyAppModule} from "./app/module";
1514

16-
bootstrapReactNative('example', Example, [/* extra providers */]);
15+
bootstrapReactNative('myApp', MyAppModule);
1716
```
1817

19-
In order to use the [Http](./http.html) and [Router](./router.html) modules, extra providers are needed. They can be passed during the bootstrap:
20-
```
21-
import {bootstrapReactNative, HTTP_PROVIDERS, ROUTER_PROVIDERS}
22-
from 'react-angular2-react-native';
23-
import {Example} from "./example";
18+
The main module must import the `ReactNativeModule`:
19+
```
20+
@NgModule({
21+
declarations: [...],
22+
imports: [ReactNativeModule, CommonModule],
23+
bootstrap: [...]
24+
})
25+
export class MyAppModule {}
2426

25-
bootstrapReactNative('example', Example, [HTTP_PROVIDERS, ROUTER_PROVIDERS]);
26-
```
27+
```
28+
29+
In order to use the [Http](./http.html) and [Router](./router.html) features, extra modules need to be imported in the main module.

doc/pages/http.jade

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,18 @@ block content
88
# Http
99

1010
The http module of Angular 2 can be used as is in applications.
11-
The only thing to be done is to bootstrap the application with the right providers (see below).
11+
The only thing to be done is to import `ReactNativeHttpModule` in the main module of the application (see below).
1212

1313
Behind the scene, it uses the [Network polyfill](https://facebook.github.io/react-native/docs/network.html) provided by React Native.
1414

15-
## bootstrap
15+
## Main module
1616
```
17-
import {bootstrapReactNative, HTTP_PROVIDERS}
18-
from 'angular2-react-native';
19-
import {Example} from "./example";
20-
21-
bootstrapReactNative('example', Example, [HTTP_PROVIDERS]);
17+
@NgModule({
18+
declarations: [...],
19+
imports: [ReactNativeModule, CommonModule, ReactNativeHttpModule],
20+
bootstrap: [...]
21+
})
22+
export class MyAppModule {}
2223
```
2324

2425
## Example

doc/pages/router.jade

Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,23 @@ block content
88
# Router
99

1010
The rooter module of Angular 2 can be used as is in applications.
11-
The only thing to be done is to bootstrap the application with the right providers (see below), and use the right directives.
11+
The only thing to be done is to import `ReactNativeRouterModule` in the main module of the application (see below), and use the static `forRoot` method to configure routes.
1212

1313
It uses a mock of `LocationStrategy`. Manipulating the location triggers a navigation of the router.
1414

15-
## bootstrap
15+
## Main module
1616
```
17-
import {bootstrapReactNative, ROUTER_PROVIDERS}
18-
from 'angular2-react-native';
19-
import {Example} from "./example";
17+
const appRoutes: Routes = [
18+
{ path: '', component: CompA },
19+
{ path: 'b', component: CompB }
20+
];
2021

21-
bootstrapReactNative('example', Example, [ROUTER_PROVIDERS]);
22+
@NgModule({
23+
declarations: [Example, CompA, CompB, ...],
24+
imports: [ReactNativeModule, CommonModule, ReactNativeRouterModule.forRoot(appRoutes)],
25+
bootstrap: [Example]
26+
})
27+
export class MyAppModule {}
2228
```
2329

2430
## Directives
@@ -28,9 +34,7 @@ block content
2834
## Example
2935
```
3036
import {Component} from '@angular/core';
31-
import {RouteConfig} from '@angular/router-deprecated';
3237
import {LocationStrategy} from '@angular/common';
33-
import {ROUTER_DIRECTIVES} from "angular2-react-native";
3438

3539
@Component({
3640
selector: 'comp-a',
@@ -49,11 +53,6 @@ block content
4953
}
5054
}
5155

52-
53-
@RouteConfig([
54-
{ path: '/', component: CompA, name: 'CompA' },
55-
{ path: '/b', component: CompB, name: 'CompB' },
56-
])
5756
@Component({
5857
selector: 'example',
5958
template: `

karma-test-shim.js

Lines changed: 34 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -31,56 +31,49 @@ System.config({
3131
System.config(
3232
{
3333
defaultJSExtensions: true,
34+
paths: {
35+
// paths serve as alias
36+
'npm:': 'node_modules/'
37+
},
3438
map: {
35-
'rxjs': 'node_modules/rxjs',
36-
'@angular': 'node_modules/@angular'
39+
// angular bundles
40+
'@angular/core': 'npm:@angular/core/bundles/core.umd.js',
41+
'@angular/common': 'npm:@angular/common/bundles/common.umd.js',
42+
'@angular/compiler': 'npm:@angular/compiler/bundles/compiler.umd.js',
43+
'@angular/platform-browser': 'npm:@angular/platform-browser/bundles/platform-browser.umd.js',
44+
'@angular/platform-browser-dynamic': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic.umd.js',
45+
'@angular/http': 'npm:@angular/http/bundles/http.umd.js',
46+
'@angular/router': 'npm:@angular/router/bundles/router.umd.js',
47+
48+
// angular testing umd bundles
49+
'@angular/core/testing': 'npm:@angular/core/bundles/core-testing.umd.js',
50+
'@angular/common/testing': 'npm:@angular/common/bundles/common-testing.umd.js',
51+
'@angular/compiler/testing': 'npm:@angular/compiler/bundles/compiler-testing.umd.js',
52+
'@angular/platform-browser/testing': 'npm:@angular/platform-browser/bundles/platform-browser-testing.umd.js',
53+
'@angular/platform-browser-dynamic/testing': 'npm:@angular/platform-browser-dynamic/bundles/platform-browser-dynamic-testing.umd.js',
54+
'@angular/http/testing': 'npm:@angular/http/bundles/http-testing.umd.js',
55+
'@angular/router/testing': 'npm:@angular/router/bundles/router-testing.umd.js',
56+
57+
// other
58+
'rxjs': 'npm:rxjs'
3759
},
3860
packages: {
39-
'@angular/core': {
40-
main: 'index.js',
41-
defaultExtension: 'js'
42-
},
43-
'@angular/compiler': {
44-
main: 'index.js',
45-
defaultExtension: 'js'
46-
},
47-
'@angular/common': {
48-
main: 'index.js',
49-
defaultExtension: 'js'
50-
},
51-
'@angular/platform-browser': {
52-
main: 'index.js',
53-
defaultExtension: 'js'
54-
},
55-
'@angular/platform-browser-dynamic': {
56-
main: 'index.js',
57-
defaultExtension: 'js'
58-
},
59-
'@angular/http': {
60-
main: 'index.js',
61-
defaultExtension: 'js'
62-
},
63-
'@angular/router-deprecated': {
64-
main: 'index.js',
65-
defaultExtension: 'js'
66-
},
6761
'rxjs': {
6862
defaultExtension: 'js'
6963
}
7064
}
7165
});
7266

73-
Promise.all([
74-
System.import('@angular/core/testing'),
75-
System.import('@angular/platform-browser-dynamic/testing')
76-
]).then(function (providers) {
77-
var testing = providers[0];
78-
var testingBrowser = providers[1];
79-
80-
testing.setBaseTestProviders(testingBrowser.TEST_BROWSER_DYNAMIC_PLATFORM_PROVIDERS,
81-
testingBrowser.TEST_BROWSER_DYNAMIC_APPLICATION_PROVIDERS);
82-
83-
}).then(function() {
67+
System.import('@angular/core/testing')
68+
.then(function(coreTesting){
69+
return System.import('@angular/platform-browser-dynamic/testing')
70+
.then(function(browserTesting) {
71+
coreTesting.TestBed.initTestEnvironment(
72+
browserTesting.BrowserDynamicTestingModule,
73+
browserTesting.platformBrowserDynamicTesting());
74+
});
75+
})
76+
.then(function() {
8477
// Finally, load all spec files.
8578
// This will run the tests directly.
8679
return Promise.all(

package.json

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"version": "0.0.1-alpha.15",
44
"description": "A React Native renderer for Angular 2",
55
"scripts": {
6-
"test": "gulp test.browser/ci && gulp test.node/ci",
6+
"test": "gulp test.browser/ci",
77
"postinstall": "typings install"
88
},
99
"repository": {
@@ -48,18 +48,18 @@
4848
"through2": "~0.6.3"
4949
},
5050
"dependencies": {
51-
"@angular/common": "v2.0.0-rc.5",
52-
"@angular/compiler": "v2.0.0-rc.5",
53-
"@angular/core": "v2.0.0-rc.5",
54-
"@angular/http": "v2.0.0-rc.5",
55-
"@angular/platform-browser": "v2.0.0-rc.5",
56-
"@angular/platform-browser-dynamic": "v2.0.0-rc.5",
57-
"@angular/platform-server": "v2.0.0-rc.5",
58-
"@angular/router-deprecated": "v2.0.0-rc.2",
51+
"@angular/common": "v2.0.0-rc.6",
52+
"@angular/compiler": "v2.0.0-rc.6",
53+
"@angular/core": "v2.0.0-rc.6",
54+
"@angular/http": "v2.0.0-rc.6",
55+
"@angular/platform-browser": "v2.0.0-rc.6",
56+
"@angular/platform-browser-dynamic": "v2.0.0-rc.6",
57+
"@angular/platform-server": "v2.0.0-rc.6",
58+
"@angular/router": "3.0.0-rc.2",
5959
"hammerjs": "2.0.6",
6060
"react-native": "0.32.0",
6161
"reflect-metadata": "0.1.8",
62-
"rxjs": "5.0.0-beta.6",
62+
"rxjs": "5.0.0-beta.11",
6363
"zone.js": "0.6.17"
6464
}
6565
}

sample/samples/android/kitchensink.ts

Lines changed: 23 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import {Component, ElementRef, ViewChild} from '@angular/core';
2-
import {Router, RouteConfig} from '@angular/router-deprecated';
2+
import {Router, NavigationEnd} from '@angular/router';
33
import {LocationStrategy} from '@angular/common';
44
import {StyleSheet, BackAndroid, Alert, NativeModules, processColor} from 'react-native';
55
import {DrawerLayout, Toolbar} from 'angular2-react-native';
66

7-
import {HelloApp} from "./hello";
87
import {TodoMVC} from "./../common/todomvc";
9-
import {GesturesApp} from "./../common/gestures";
10-
import {WidgetsList} from "./widgets";
11-
import {WebViewApp} from './../common/webview';
12-
import {APIsList} from "./apis";
13-
import {HttpApp} from "./../common/http";
14-
import {AnimationApp} from './../common/animation';
158

169
@Component({
1710
selector: 'kitchensink-app',
@@ -22,42 +15,35 @@ import {AnimationApp} from './../common/animation';
2215
<Toolbar [styleSheet]="styles.toolbar" [navIcon]="hamburgerIcon" [overflowIcon]="moreIcon"
2316
title="Kitchen Sink" titleColor="#FFFFFF" (select)="handleToolbar($event)"></Toolbar>
2417
<View [styleSheet]="styles.content">
25-
<router-outlet></router-outlet>
18+
<router-outlet (activate)="_lastActivated = $event"></router-outlet>
2619
</View>
2720
</DrawerLayoutSide>
2821
<DrawerLayoutContent>
2922
<View [styleSheet]="styles.drawer">
30-
<View *ngFor="let item of menuItems" [styleSheet]="styles.menuItem" [routerLink]="['/' + item.as]" rippleFeedback="#00a9e0">
23+
<View *ngFor="let item of menuItems" [styleSheet]="styles.menuItem" [routerLink]="item.as" rippleFeedback="#00a9e0">
3124
<Text [styleSheet]="styles.menuText">{{item.name}}</Text>
3225
</View>
3326
</View>
3427
</DrawerLayoutContent>
3528
</DrawerLayout>
3629
`
3730
})
38-
@RouteConfig([
39-
{ path: '/', component: HelloApp, name: 'HelloApp' },
40-
{ path: '/todomvc', component: TodoMVC, name: 'TodoMVC' },
41-
{ path: '/gestures', component: GesturesApp, name: 'GesturesApp' },
42-
{ path: '/widgets', component: WidgetsList, name: 'WidgetsList' },
43-
{ path: '/webview', component: WebViewApp, name: 'WebViewApp' },
44-
{ path: '/apis', component: APIsList, name: 'APIsList' },
45-
{ path: '/http', component: HttpApp, name: 'HttpApp' },
46-
{ path: '/animation', component: AnimationApp, name: 'AnimationApp'}
47-
])
4831
export class KitchenSinkApp {
49-
@ViewChild(TodoMVC) viewChild: TodoMVC;
32+
private _lastActivated: any;
33+
private _todoMVC: TodoMVC;
5034
@ViewChild(DrawerLayout) drawerLayout: DrawerLayout;
5135
@ViewChild(Toolbar) toolbar: Toolbar;
5236
hamburgerIcon: any = require('../../assets/icon_hamburger.png');
5337
moreIcon: any = require('../../assets/icon_more.png');
54-
menuItems: Array<any> = [{name: 'Hello world', as: 'HelloApp'}, {name: 'Components', as: 'WidgetsList'}, {name: 'WebView', as: 'WebViewApp'}, {name: 'APIs', as: 'APIsList'},
55-
{name: 'TodoMVC', as: 'TodoMVC'}, {name: 'Gestures', as: 'GesturesApp'}, {name: 'Http', as: 'HttpApp'}, {name: 'Animation', as: 'AnimationApp'}]
38+
menuItems: Array<any> = [{name: 'Hello world', as: ''}, {name: 'Components', as: 'widgets'}, {name: 'WebView', as: 'webview'}, {name: 'APIs', as: 'apis'},
39+
{name: 'TodoMVC', as: 'todomvc'}, {name: 'Gestures', as: 'gestures'}, {name: 'Http', as: 'http'}, {name: 'Animation', as: 'animation'}]
5640
styles: any;
5741
_el : any = null;
5842
constructor(el: ElementRef, private router: Router, private locationStrategy: LocationStrategy) {
59-
this.router.subscribe((res) => {
60-
this._afterNavigate(res.instruction.urlPath);
43+
this.router.events.subscribe((res) => {
44+
if (res instanceof NavigationEnd) {
45+
this._afterNavigate(res.url.substring(1));
46+
}
6147
})
6248
NativeModules.StatusBarManager.setColor(processColor('#00a9e0'), true);
6349

@@ -114,25 +100,27 @@ export class KitchenSinkApp {
114100
this.drawerLayout.closeDrawer();
115101
if (url == 'todomvc') {
116102
this._addMoreInToolbar();
103+
this._todoMVC = this._lastActivated;
117104
} else {
118105
this._removeMoreInToolbar();
106+
this._todoMVC = null;
119107
}
120108
}
121109

122110
handleToolbar(event: any) {
123111
var position = event.position;
124112
if (position == -1) {
125113
this.drawerLayout.openDrawer();
126-
} else if (position == 0 && this.viewChild) {
127-
this.viewChild.reset();
128-
} else if (position == 1 && this.viewChild) {
129-
this.viewChild.empty();
130-
} else if (position == 2 && this.viewChild) {
131-
this.viewChild.full();
132-
} else if (position == 3 && this.viewChild) {
133-
this.viewChild.save();
134-
} else if (position == 4 && this.viewChild) {
135-
this.viewChild.load();
114+
} else if (position == 0 && this._todoMVC) {
115+
this._todoMVC.reset();
116+
} else if (position == 1 && this._todoMVC) {
117+
this._todoMVC.empty();
118+
} else if (position == 2 && this._todoMVC) {
119+
this._todoMVC.full();
120+
} else if (position == 3 && this._todoMVC) {
121+
this._todoMVC.save();
122+
} else if (position == 4 && this._todoMVC) {
123+
this._todoMVC.load();
136124
}
137125
}
138126

sample/samples/android/module.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,32 @@
11
import {NgModule} from '@angular/core';
22
import {CommonModule} from '@angular/common';
3-
import {ReactNativeModule} from 'angular2-react-native';
3+
import {Routes} from '@angular/router';
4+
import {ReactNativeModule, ReactNativeRouterModule, ReactNativeHttpModule} from 'angular2-react-native';
45
import {KitchenSinkApp} from './kitchensink';
56

7+
import {HelloApp} from "./hello";
68
import {TodoMVC, TodoItem} from '../common/todomvc';
7-
import {Ball} from '../common/animation';
9+
import {GesturesApp} from "./../common/gestures";
10+
import {WidgetsList} from "./widgets";
11+
import {WebViewApp} from './../common/webview';
12+
import {APIsList} from "./apis";
13+
import {HttpApp} from "./../common/http";
14+
import {AnimationApp, Ball} from './../common/animation';
15+
16+
const appRoutes: Routes = [
17+
{ path: '', component: HelloApp },
18+
{ path: 'todomvc', component: TodoMVC },
19+
{ path: 'gestures', component: GesturesApp },
20+
{ path: 'widgets', component: WidgetsList },
21+
{ path: 'webview', component: WebViewApp },
22+
{ path: 'apis', component: APIsList },
23+
{ path: 'http', component: HttpApp },
24+
{ path: 'animation', component: AnimationApp }
25+
];
826

927
@NgModule({
10-
declarations: [KitchenSinkApp, TodoMVC, TodoItem, Ball],
11-
imports: [ReactNativeModule, CommonModule],
28+
declarations: [KitchenSinkApp, HelloApp, TodoMVC, TodoItem, GesturesApp, WidgetsList, WebViewApp, APIsList, HttpApp, AnimationApp, Ball],
29+
imports: [ReactNativeModule, ReactNativeHttpModule, CommonModule, ReactNativeRouterModule.forRoot(appRoutes)],
1230
bootstrap: [KitchenSinkApp]
1331
})
1432
export class KitchenSinkModule {}

0 commit comments

Comments
 (0)