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 'package:flutter/material.dart'; | |
import 'package:meta/meta.dart'; | |
class AppConfig extends InheritedWidget { | |
AppConfig({ | |
@required this.flavorName, | |
@required this.apiBaseUrl, | |
@required Widget child, | |
}) : super(child: child); |
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 {NgModule} from '@angular/core'; | |
import {BrowserModule} from '@angular/platform-browser'; | |
import {HTTP_INTERCEPTORS, HttpClientModule} from '@angular/common/http'; | |
import {AppComponent} from './app.component'; | |
import {BaseURLInterceptor} from './services/base-url.interceptor'; | |
import {HttpErrorInterceptor} from './services/http-error.interceptor'; | |
@NgModule({ | |
declarations: [ AppComponent ], |
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 {Injectable} from '@angular/core'; | |
import {HttpHandler, HttpRequest, HttpInterceptor} from '@angular/common/http'; | |
import {throwError} from 'rxjs'; | |
import {catchError} from 'rxjs/internal/operators'; | |
import {ErrorService} from '../my-services/error.service'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class HttpErrorInterceptor implements HttpInterceptor { |
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 { Injectable } from '@angular/core'; | |
import {HttpHandler, HttpRequest, HttpInterceptor} from '@angular/common/http'; | |
import {environment} from '../../environments/environment'; | |
@Injectable({ | |
providedIn: 'root' | |
}) | |
export class BaseURLInterceptor implements HttpInterceptor { | |
intercept(req: HttpRequest<any>, next: HttpHandler) { | |
if (!req.url.match(/^http(s)?:\/\/(.*)$/)) { |
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
// GetItem finds a returns a single item from a dynamodb table. | |
// It returns an element and an error if any. | |
// If no element is found, will return nil without an error | |
func GetItem(id string, dest interface{}) error { | |
tableName := "table-name" | |
// create get operation information | |
item := &dynamodb.GetItemInput{ | |
TableName: aws.String(tableName), | |
Key: map[string]*dynamodb.AttributeValue{ |
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 { Component, OnInit } from '@angular/core'; | |
import { FormControl } from '@angular/forms'; | |
import { Observable } from 'rxjs'; | |
import { switchMap, debounceTime } from 'rxjs/operators'; | |
import { PlanetService } from '../planet.service'; | |
import { Planet } from '../planet'; | |
@Component({ | |
selector: 'app-search-bar', | |
templateUrl: './search-bar.component.html' |
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="p-4"> | |
<p class="mb-2">search-bar works!</p> | |
<div class="relative"> | |
<input [formControl]="search" type="text" class="border border-grey rounded shadow-inner p-2 w-full" placeholder="Search..."> | |
<div class="absolute mt-1 bg-grey w-full rounded shadow"> | |
<ul class="list-reset"> | |
<li *ngFor="let planet of (planets$ | async)" class="p-2">{{ planet.name }}</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
import { Component, OnInit } from '@angular/core'; | |
import { FormControl } from '@angular/forms'; | |
import { Observable } from 'rxjs'; | |
import { switchMap } from 'rxjs/operators'; | |
import { PlanetService } from '../planet.service'; | |
import { Planet } from '../planet'; | |
@Component({ | |
selector: 'app-search-bar', | |
templateUrl: './search-bar.component.html' |
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 { NgModule } from '@angular/core'; | |
import { BrowserModule } from '@angular/platform-browser'; | |
import { ReactiveFormsModule } from '@angular/forms'; | |
import { HttpClientModule } from '@angular/common/http'; | |
import { AppComponent } from './app.component'; | |
import { SearchBarComponent } from './search-bar/search-bar.component'; | |
import { PlanetService } from './planet.service'; | |
@NgModule({ |
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
export interface Planet { | |
name: string; | |
rotation_period: number; | |
orbital_period: number; | |
diameter: number; | |
climate: string; | |
gravity: string; | |
terrain: string; | |
surface_water: number; | |
population: number; |