Skip to content

Commit c249339

Browse files
commented code, tslint & readme updated
1 parent ded017e commit c249339

File tree

10 files changed

+26
-12
lines changed

10 files changed

+26
-12
lines changed

.firebaserc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"projects": {
3-
"default": "ionic-angular-pr-1565107344855"
3+
"default": "ionic-angular-pr-1565107344855",
4+
"testing": "ionic-angular-pr-1565107344855"
45
}
56
}

README.md

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,19 @@ Code taken from course.
2929

3030
**of** used with a single value for an 'emit once and complete' stream.
3131

32-
**take** tba
32+
**take** emits only the first n values from an observable (e.g. take(1) emits only the first 2 values )
3333

34-
**tap** tba
34+
**tap** used to perform side effects. Every data value is received from the source, an action is taken on a part of the data then the data passeed on unchanged.
35+
36+
**map** passes each source value through a transformation function then outputs the results, e.g map(x => 10*x)
37+
38+
## Observables
39+
40+
An [observable](https://rxjs-dev.firebaseapp.com/guide/observable) is created using 'new Observable'. It is subscribed to using an Observer and executed to deliver next / error / complete notices to the Observer, before the execution is disposed of. Sbscribers should be wrapped in try/catch blocks.
41+
42+
## Array Operators
43+
44+
* [Array.push()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push) adds one or more elements to the end of an array and returns the new aray length.
3545

3646
## Screenshots
3747

src/app/auth/auth.guard.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@ export class AuthGuard implements CanLoad {
2626
}),
2727
tap(isAuthenticated => {
2828
if (!isAuthenticated) {
29-
this.router.navigateByUrl('/auth');
30-
}
29+
this.router.navigateByUrl('/auth');
30+
}
3131
})
3232
);
3333
}

src/app/auth/auth.page.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ export class AuthPage implements OnInit {
4040
}
4141
authObs.subscribe(
4242
resData => {
43-
console.log(resData);
4443
this.isLoading = false;
4544
loadingEl.dismiss();
4645
this.router.navigateByUrl('/places/tabs/discover');

src/app/auth/auth.service.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export interface AuthResponseData {
2121
providedIn: 'root'
2222
})
2323
export class AuthService implements OnDestroy {
24-
// tslint:disable-next-line: variable-name
24+
2525
private _user = new BehaviorSubject<User>(null);
2626
private activeLogoutTimer: any;
2727

@@ -181,7 +181,6 @@ export class AuthService implements OnDestroy {
181181
tokenExpirationDate,
182182
email
183183
});
184-
console.log('auth data: ', data);
185184
Plugins.Storage.set({ key: 'authData', value: data });
186185
}
187186
}

src/app/bookings/booking.service.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ interface BookingData {
2020

2121
@Injectable({ providedIn: 'root' })
2222
export class BookingService {
23-
// tslint:disable-next-line: variable-name
2423
private _bookings = new BehaviorSubject<Booking[]>([]);
2524

2625
get bookings() {

src/app/bookings/bookings.page.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export class BookingsPage implements OnInit, OnDestroy {
2727
});
2828
}
2929

30+
// lifecycle event fired when entering a page
3031
ionViewWillEnter() {
3132
this.isLoading = true;
3233
this.bookingService.fetchBookings().subscribe(() => {

src/app/places/places-routing.module.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import { RouterModule, Routes } from '@angular/router';
22
import { NgModule } from '@angular/core';
3+
34
import { PlacesPage } from './places.page';
45

56
const routes: Routes = [

src/app/places/places.service.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ interface PlaceData {
5555
providedIn: 'root'
5656
})
5757
export class PlacesService {
58-
// tslint:disable-next-line: variable-name
5958
private _places = new BehaviorSubject<Place[]>([]);
6059

6160
get places() {
@@ -101,7 +100,7 @@ export class PlacesService {
101100

102101
getPlace(id: string) {
103102
return this.authService.token.pipe(
104-
take(1),
103+
take(1), // only need one token
105104
switchMap(token => {
106105
return this.http.get<PlaceData>(
107106
`https://ionic-angular-pr-1565107344855.firebaseio.com/offered-places/${id}.json?auth=${token}`
@@ -131,7 +130,8 @@ export class PlacesService {
131130
take(1),
132131
switchMap(token => {
133132
return this.http.post<{ imageUrl: string, imagePath: string }>(
134-
'https://us-central1-ionic-angular-pr-1565107344855.cloudfunctions.net/storeImage',
133+
// 'https://eur3-ionic-angular-pr-1565107344855.cloudfunctions.net/storeImage',
134+
'gs://ionic-angular-pr-1565107344855.appspot.com/',
135135
uploadData, {headers: { Authorization: 'Bearer ' + token } }
136136
);
137137
})

tslint.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44
"codelyzer"
55
],
66
"rules": {
7+
"variable-name": [true,
8+
"check-format",
9+
"allow-leading-underscore"
10+
],
711
"indent": [
812
true,
913
"tabs",

0 commit comments

Comments
 (0)