
committed by
Rado Kirov

parent
800c8f196f
commit
8bea667a0b
11
modules/playground/src/web_workers/router/app.html
Normal file
11
modules/playground/src/web_workers/router/app.html
Normal file
@ -0,0 +1,11 @@
|
||||
<nav>
|
||||
<ul>
|
||||
<li class="start" [routerLink]="['/Start']">Start</li>
|
||||
<li class="about" [routerLink]="['/About']">About</li>
|
||||
<li class="contact" [routerLink]="['/Contact']">Contact</li>
|
||||
</ul>
|
||||
</nav>
|
||||
<main>
|
||||
<router-outlet></router-outlet>
|
||||
</main>
|
||||
|
@ -0,0 +1,20 @@
|
||||
library playground.src.web_workers.router.background_index;
|
||||
|
||||
import "index_common.dart" show App;
|
||||
import "dart:isolate";
|
||||
import "package:angular2/platform/worker_app.dart";
|
||||
import "package:angular2/core.dart";
|
||||
import "package:angular2/src/web_workers/worker/router_providers.dart";
|
||||
import "package:angular2/router.dart";
|
||||
|
||||
@AngularEntrypoint()
|
||||
main(List<String> args, SendPort replyTo) {
|
||||
platform([
|
||||
WORKER_APP_PLATFORM,
|
||||
new Provider(RENDER_SEND_PORT, useValue: replyTo)
|
||||
]).asyncApplication(null, [
|
||||
WORKER_APP_APPLICATION,
|
||||
WORKER_APP_ROUTER,
|
||||
new Provider(LocationStrategy, useClass: HashLocationStrategy)
|
||||
]).then((ref) => ref.bootstrap(App));
|
||||
}
|
@ -0,0 +1,18 @@
|
||||
import {platform, Provider, NgZone} from "angular2/core";
|
||||
import {
|
||||
WORKER_APP_PLATFORM,
|
||||
WORKER_APP_APPLICATION,
|
||||
WORKER_APP_ROUTER
|
||||
} from "angular2/platform/worker_app";
|
||||
import {App} from "./index_common";
|
||||
import {HashLocationStrategy, LocationStrategy} from "angular2/router";
|
||||
|
||||
export function main() {
|
||||
let refPromise = platform([WORKER_APP_PLATFORM])
|
||||
.asyncApplication(null, [
|
||||
WORKER_APP_APPLICATION,
|
||||
WORKER_APP_ROUTER,
|
||||
new Provider(LocationStrategy, {useClass: HashLocationStrategy})
|
||||
]);
|
||||
refPromise.then((ref) => ref.bootstrap(App));
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
import {Component} from 'angular2/core';
|
||||
@Component({selector: 'about', template: '<h1>About</h1>'})
|
||||
export class About {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
import {Component} from 'angular2/core';
|
||||
@Component({selector: 'contact', template: '<h1>Contact</h1>'})
|
||||
export class Contact {
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
import {Component} from 'angular2/core';
|
||||
@Component({selector: 'start', template: '<h1>Start</h1>'})
|
||||
export class Start {
|
||||
}
|
13
modules/playground/src/web_workers/router/index.dart
Normal file
13
modules/playground/src/web_workers/router/index.dart
Normal file
@ -0,0 +1,13 @@
|
||||
library angular2.examples.web_workers.router.index;
|
||||
|
||||
import "package:angular2/platform/worker_render.dart";
|
||||
import "package:angular2/core.dart";
|
||||
import "package:angular2/src/core/reflection/reflection_capabilities.dart";
|
||||
import "package:angular2/src/core/reflection/reflection.dart";
|
||||
|
||||
@AngularEntrypoint()
|
||||
main() {
|
||||
reflector.reflectionCapabilities = new ReflectionCapabilities();
|
||||
platform([WORKER_RENDER_PLATFORM]).asyncApplication(
|
||||
initIsolate("background_index.dart"), [WORKER_RENDER_ROUTER]);
|
||||
}
|
8
modules/playground/src/web_workers/router/index.html
Normal file
8
modules/playground/src/web_workers/router/index.html
Normal file
@ -0,0 +1,8 @@
|
||||
<!doctype html>
|
||||
<html>
|
||||
<title>Web Worker Router Example</title>
|
||||
<body>
|
||||
<app></app>
|
||||
$SCRIPTS$
|
||||
</body>
|
||||
</html>
|
16
modules/playground/src/web_workers/router/index.ts
Normal file
16
modules/playground/src/web_workers/router/index.ts
Normal file
@ -0,0 +1,16 @@
|
||||
import {platform, Provider} from 'angular2/core';
|
||||
import {
|
||||
WORKER_RENDER_APP,
|
||||
WORKER_RENDER_PLATFORM,
|
||||
WORKER_SCRIPT,
|
||||
WORKER_RENDER_ROUTER
|
||||
} from 'angular2/platform/worker_render';
|
||||
import {BrowserPlatformLocation} from "angular2/src/router/browser_platform_location";
|
||||
import {MessageBasedPlatformLocation} from "angular2/src/web_workers/ui/platform_location";
|
||||
|
||||
let ref = platform([WORKER_RENDER_PLATFORM])
|
||||
.application([
|
||||
WORKER_RENDER_APP,
|
||||
new Provider(WORKER_SCRIPT, {useValue: "loader.js"}),
|
||||
WORKER_RENDER_ROUTER
|
||||
]);
|
14
modules/playground/src/web_workers/router/index_common.ts
Normal file
14
modules/playground/src/web_workers/router/index_common.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import {Component, View} from 'angular2/core';
|
||||
import {Start} from './components/start';
|
||||
import {About} from './components/about';
|
||||
import {Contact} from './components/contact';
|
||||
import {ROUTER_DIRECTIVES, RouteConfig, Route} from 'angular2/router';
|
||||
|
||||
@Component({selector: 'app', directives: [ROUTER_DIRECTIVES], templateUrl: 'app.html'})
|
||||
@RouteConfig([
|
||||
new Route({path: '/', component: Start, name: "Start"}),
|
||||
new Route({path: '/contact', component: Contact, name: "Contact"}),
|
||||
new Route({path: '/about', component: About, name: "About"})
|
||||
])
|
||||
export class App {
|
||||
}
|
17
modules/playground/src/web_workers/router/loader.js
Normal file
17
modules/playground/src/web_workers/router/loader.js
Normal file
@ -0,0 +1,17 @@
|
||||
$SCRIPTS$
|
||||
|
||||
System.config({
|
||||
baseURL: '/',
|
||||
defaultJSExtensions: true
|
||||
});
|
||||
|
||||
System.import("playground/src/web_workers/router/background_index")
|
||||
.then(
|
||||
function(m) {
|
||||
try {
|
||||
m.main();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
},
|
||||
function(error) { console.error("error loading background", error); });
|
Reference in New Issue
Block a user