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 const { loginAction, loginActionTypes, loginReducer } = reduxHelper('login', function(username, password) { | |
return api.login('username', 'password') | |
}) |
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
function middleware({dispatch}) { | |
return next => action => { | |
if (typeof action === 'function') { | |
return action(dispatch) | |
} | |
return next(action) | |
} | |
} |
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
// we are not using arrow function, because there no arguments binding | |
// https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions | |
function action() { | |
const args = arguments | |
return dispatch => { | |
dispatch({ | |
type: actionRequest | |
}) | |
try { | |
const result = fn.apply(this, args) |
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 actionRequest = actionName + '_REQUEST' | |
const actionSuccess = actionName + '_SUCCESS' | |
const actionFailure = actionName + '_FAILURE' | |
const initialState = { | |
data: null, | |
loading: false, | |
error: null | |
} |
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
function login(username, password) { | |
return dispatch => { | |
dispatch({ | |
type: 'LOGIN_REQUEST' | |
}) | |
api.login(username, password) | |
.then(user => dispatch({ | |
type: 'LOGIN_SUCCESS', | |
user | |
})) |
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 initialState = { | |
loading: false, | |
user: null, | |
error: null | |
} | |
export default function (state = initialState, action) { | |
switch(action.type) { | |
case 'LOGIN_REQUEST': | |
return { |
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
function reduxHelper (actionName, fn) { | |
if (typeof actionName !== 'string') { | |
throw new Error('actionName must be a string') | |
} | |
if (typeof fn !== 'function') { | |
throw new Error('fn must be a function') | |
} | |
const actionNameUpper = actionName.toUpperCase() | |
const actionRequest = actionNameUpper + '_REQUEST' | |
const actionSuccess = actionNameUpper + '_SUCCESS' |
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
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases. | |
; #Warn ; Enable warnings to assist with detecting common errors. | |
SendMode Input ; Recommended for new scripts due to its superior speed and reliability. | |
SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory. | |
^f9::Send {Media_Prev} | |
^f10::Send {Media_Next} | |
^f11::Send {Volume_Down} | |
^f12::Send {Volume_Up} |
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
<?php | |
require 'vendor/autoload.php'; | |
$app = new \Slim\App; | |
$app->get('/hello', function($request, $response) { | |
$response->getBody()->write("Hello, $name"); | |
return $response; |
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: '2' | |
services: | |
web: | |
# build image dari Dockerfile dalam directory yang sama | |
build: . | |
ports: | |
# {host}:{docker} | |
- 9090:8080 | |
volumes: | |
# mount semua source code project ke directory /app pada docker container |