Skip to content

Commit ed8a240

Browse files
committed
first commits
1 parent dfa3f2e commit ed8a240

7 files changed

+83
-1
lines changed

.vscode/settings.json

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"typescript.tsdk": "./node_modules/typescript/lib"
3+
}

src/app/app.component.html

+2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
<h1>
22
{{title}}
33
</h1>
4+
5+
<app-pun-lookup></app-pun-lookup>

src/app/app.module.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,12 @@ import { FormsModule } from '@angular/forms';
44
import { HttpModule } from '@angular/http';
55

66
import { AppComponent } from './app.component';
7+
import { PunLookupComponent } from './pun-lookup/pun-lookup.component';
78

89
@NgModule({
910
declarations: [
10-
AppComponent
11+
AppComponent,
12+
PunLookupComponent
1113
],
1214
imports: [
1315
BrowserModule,

src/app/app.rx.ts

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
export { Observable } from 'rxjs/Observable';
2+
export { asap } from 'rxjs/Scheduler/asap';
3+
export { Subject } from 'rxjs/Subject';
4+
5+
import 'rxjs/add/observable/of';
6+
import 'rxjs/add/operator/map';
7+
import 'rxjs/add/operator/filter';
8+
import 'rxjs/add/operator/do';
+30
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import { Component, OnInit } from '@angular/core';
2+
import { Subject, Observable } from '../app.rx';
3+
4+
@Component({
5+
selector: 'app-pun-lookup',
6+
template: `
7+
<input #keywords type="text"
8+
(input)="keywordsInputChange$.next(keywords.value)"/>
9+
<hr/>
10+
<div>{{foo$ | async}}</div>
11+
`,
12+
styles: []
13+
})
14+
export class PunLookupComponent implements OnInit {
15+
16+
keywordsInputChange$ = new Subject<string>();
17+
18+
foo$ = this.keywordsInputChange$
19+
.map(x => x[x.length - 1] === 'f' ? '' : x + '!')
20+
// .filter(x => x.indexOf('f') === -1)
21+
// .map(x => x + '!');
22+
23+
24+
constructor() {
25+
}
26+
27+
ngOnInit() {
28+
}
29+
30+
}

src/app/pun-service.service.spec.ts

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
/* tslint:disable:no-unused-variable */
2+
3+
import { TestBed, async, inject } from '@angular/core/testing';
4+
import { PunService } from './pun-service.service';
5+
6+
describe('PunService', () => {
7+
beforeEach(() => {
8+
TestBed.configureTestingModule({
9+
providers: [PunService]
10+
});
11+
});
12+
13+
it('should ...', inject([PunService], (service: PunService) => {
14+
expect(service).toBeTruthy();
15+
}));
16+
});

src/app/pun-service.service.ts

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { Injectable } from '@angular/core';
2+
import { Observable, asap } from './app.rx';
3+
4+
export interface Pun {
5+
keywords: string[],
6+
text: string
7+
}
8+
9+
@Injectable()
10+
export class PunService {
11+
12+
constructor() { }
13+
14+
getPuns(keywords: string[]): Observable<Pun> {
15+
return Observable.of({
16+
keywords: ['pickle', 'vegetable'],
17+
text: 'this is a pun about a pickle'
18+
}, asap);
19+
}
20+
21+
}

0 commit comments

Comments
 (0)