This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useState, useMemo } from "react"; | |
const fibonacci = n => { | |
if (n <= 1) { | |
return 1; | |
} | |
return fibonacci(n - 1) + fibonacci(n - 2); | |
}; | |
const MemoComponent = () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class UsersService { | |
constructor(private http: HttpClient, private postsService: PostsService) { } | |
private userSelectedAction = new Subject<number>(); | |
private usersUrl = 'https://jsonplaceholder.typicode.com/users'; | |
user$ = this.http.get<Users>(this.usersUrl).pipe(shareReplay()); | |
userWithPost$ = combineLatest( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'my-app', | |
templateUrl: './app.component.html', | |
styleUrls: [ './app.component.css' ], | |
changeDetection: ChangeDetectionStrategy.OnPush | |
}) | |
export class AppComponent { | |
user$ = this.usersService.user$; | |
userWithPost$ = this.usersService.userWithPost$; | |
selectedUser$ = this.usersService.selectedUser$; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<div class="container"> | |
<div class="block"> | |
<h1>List of users</h1> | |
<ul *ngIf="userWithPost$ | async as userList"> | |
<li *ngFor="let user of userList"> | |
<a href="#" (click)="selectUser(user.id)">{{user.username}}</a> | |
</li> | |
</ul> | |
</div> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Component({ | |
selector: 'app-books', | |
templateUrl: './books.component.html' | |
}) | |
export class BooksComponent implements OnDestroy, OnInit { | |
private ngUnsubscribe = new Subject(); | |
constructor(private booksService: BookService) { } | |
ngOnInit() { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
arrowParens: 'avoid', | |
bracketSpacing: true, | |
htmlWhitespaceSensitivity: 'css', | |
jsxBracketSameLine: false, | |
printWidth: 80, | |
proseWrap: 'preserve', | |
requirePragma: false, | |
semi: true, | |
singleQuote: true, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
``` | |
setState() | |
- is Asynchronous | |
- can have a function as a parameter instead of object | |
- can accepts a Callback function as a second argument (optional) | |
- does not return promise | |
``` | |
function updateState(){ | |
this.setState({load: true}, () => { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.5' | |
services: | |
zota_mongo: | |
volumes: | |
- mongo_data:/data/configdb | |
- mongo_data:/data/mysql | |
gateway: | |
volumes: | |
- ./proxy/default.conf:/etc/nginx/conf.d/default.conf:ro | |
- ./proxy/ssl:/etc/nginx/ssl:ro |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3.5' | |
services: | |
gateway: | |
image: nginx:1.11 | |
ports: | |
- 88:80 | |
- 443:443 | |
depends_on: | |
- zota_car | |
- zota_company |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM node:carbon | |
WORKDIR /usr/src/app | |
ARG GIT_TOKEN | |
COPY package.json package-lock.json .npmrc ./ | |
RUN npm install | |
RUN rm -f .npmrc | |
# Add your source files | |
COPY . . | |
EXPOSE 3000 | |
RUN npm run build |