- GitHub Staff
- @david_losert
This file contains 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
#!/usr/bin/env bash | |
# replace this variable | |
NAMESPACE="<NAMESPACE>" | |
function deletePod { | |
kubectl delete pod psql-client --namespace=$NAMESPACE | |
} | |
trap deletePod EXIT |
This file contains 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 { Menu } from './Menu'; | |
import { MenuModel } from './MenuModel'; | |
import React from 'react'; | |
export class App extends React.Component<any, IAppState> { | |
public constructor (props: any) { | |
super(props); | |
const mockMenuService: MockMenuService = new MockMenuService(); | |
const menu: MenuModel = mockMenuService.getMenu(); |
This file contains 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
class MyClass { | |
greet: () => console.log('Hello World') | |
} | |
const myObject = { | |
...new MyClass() | |
} | |
// will throw "myObject.greet" is not a function as the greeting is on the prototype, not the acutal instantiated class object | |
myObject.greet() |
This file contains 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
declare var MOCK_API: boolean; | |
const todoRepository = MOCK_API ? | |
createMockTodoRepository() | |
: createHTTPTodoRepository('https://jsonplaceholder.typicode.com'); | |
const initialState = {loading: false, todos: []}; | |
const store = createStore<TodoListState>(todo, initialState, | |
applyMiddleware( | |
thunk.withExtraArgument(todoRepository()) |
This file contains 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 {Todo} from '../../state/Todo'; | |
import {TodoRepository} from '../TodoRepository'; | |
export const createMockTodoRepository = (): TodoRepository => ({ | |
loadAllTODOs: () => Promise.resolve(createMockTodos()) | |
}); | |
const emptyArray = Array(1000).fill(0); | |
const createMockTodos = () => emptyArray.map((val, index) => |
This file contains 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 {TodoRepository} from './TodoRepository'; | |
import {loadingTodos, loadTodosSuccess} from '../state/todo.actions'; | |
import {Todo} from '../state/Todo'; | |
export const fetchAllTodos = () => | |
(dispatch, getState, todoRepository: TodoRepository) => { | |
dispatch(loadingTodos()); | |
todoRepository.loadAllTODOs().then((todos: Todo[]) => { | |
dispatch(loadTodosSuccess(todos)); | |
}); |
This file contains 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 {createHTTPTodoRepository} from './todo-repository/http/HttpTodoRepository'; | |
const initialState = {loading: false, todos: []}; | |
const store = createStore<TodoListState>(todo, initialState, | |
applyMiddleware( | |
thunk.withExtraArgument(createHTTPTodoRepository()) | |
) | |
); |
This file contains 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 {TodoRepository} from '../TodoRepository'; | |
export const createHTTPTodoRepository = (baseURL: string): TodoRepository => { | |
return { | |
loadAllTODOs: () => fetch(`${baseURL}/todos`).then(result => result.json()) | |
} | |
}; |
This file contains 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 {Todo} from '../state/Todo'; | |
export interface TodoRepository { | |
loadAllTODOs(): Promise<Todo[]>; | |
} |
This file contains 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 {loadingTodos, loadTodosSuccess} from '../state/todo.actions'; | |
export const fetchAllTodos = () => | |
(dispatch, getState, todoRepository: TodoRepository) => { | |
dispatch(loadingTodos()); | |
fetch('https://jsonplaceholder.typicode.com/todos') | |
.then(result => result.json()) | |
.then(todos => dispatch(loadTodosSuccess(todos))) | |
}; |
NewerOlder