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
| // Delete all data in elasticsearch | |
| curl -X DELETE 'http://localhost:9200/_all' | |
| // Backup data to data.json | |
| elasticdump --input=data.json --output=http://localhost:9200 --type=data | |
| // Import data.json to elasticsearch | |
| elasticdump --input=http://localhost:9200/ --output=data.json --type=data --limit 50000 | |
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
| const observable = of('response') | |
| observable.subscribe(result => { | |
| // Do the logic with the result emited by the observable | |
| // ................. | |
| // ................. | |
| // ................. | |
| }); |
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
| const observable = of('response') | |
| observable.pipe(first()).subscribe(result => { | |
| // Do the logic with the result emited by the observable | |
| // ................. | |
| // ................. | |
| // ................. | |
| }); |
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
| const observable = of('response') | |
| const result = await getValue(observable) | |
| // Do the logic with the result | |
| // ................. | |
| // ................. | |
| // ................. |
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
| const observable = of('response') | |
| function hasValue(value: any) { | |
| return value !== null && value !== undefined; | |
| } | |
| function getValue<T>(observable: Observable<T>): Promise<T> { | |
| return observable | |
| .pipe( | |
| filter(hasValue), |
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
| const iAmAwesome = true; | |
| iAmAwesome = false; // Cannot assign to 'iAmAwesome' because it is a constant |
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
| interface User { | |
| id: number; | |
| name: string; | |
| } | |
| const user: User = { | |
| id: 1, | |
| name: "Keerati" | |
| }; |
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
| interface User { | |
| readonly id: number; | |
| name: string; | |
| } | |
| const user: User = { | |
| id: 1, | |
| name: "Keerati" | |
| }; |
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
| const numbers: number[] = [1, 2, 3, 4, 5]; | |
| numbers.push(6); // There is nothing wrong with this |
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
| const numbers: ReadonlyArray<number> = [1, 2, 3, 4, 5]; | |
| numbers.push(6); // Property 'push' does not exist on type 'ReadonlyArray<number>' |