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 | |
#.... | |
protected array $listeners = []; | |
public function getState() | |
{ | |
return $this->state; | |
} | |
public function subscribe(callable $listener) |
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 | |
$store->subscribe(function($state) { | |
print_r($state); | |
}); | |
# Que diriez-vous d'un envoi : | |
# ... | |
public function dispatch(array $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
<?php | |
class Store | |
{ | |
protected array $state; | |
protected Closure $reducer; | |
protected array $listeners = []; | |
public function __construct( callable $reducer, array $initialState) | |
{ |
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 | |
const INCREMENT_BY_ACTION = 'INCREMENT_BY'; | |
function countReducer(array $state, $action) { | |
switch($action['type']) { | |
case INCREMENT_BY_ACTION; | |
$value = $action['value'] ?? 0; | |
return array_replace([], $state, ['count' => $state['count'] + $value]); | |
case INCREMENT_ACTION: | |
return array_replace([], $state, ['count' => $state['count'] + 1]); |
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
rootReducer = combineReducers({potato: potatoReducer, tomato: tomatoReducer}); |
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 | |
function combineReducers(array $reducers) { | |
return function(array $state, $action) use ($reducers) { | |
$newState = $state; | |
foreach($reducers as $stateKey => $reducer) { | |
if(!isset($newState[$stateKey])) { | |
$newState[$stateKey] = []; | |
} | |
$newState[$stateKey] = $reducer($newState[$stateKey], $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
<?php | |
$initialState = [ | |
'count' => [ | |
'count' => 1 | |
], | |
'sum' => 0 | |
]; | |
function sumReducer($state, $action) { | |
switch($action['type']) { |
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
set -g status-justify left # Aligne les titres de fenetres a gauche | |
set -g status-bg colour1 # Status bar noir sur rouge | |
set -g status-fg colour0 # | |
set -g status-interval 2 # Evite des bug de refraichissement | |
setw -g window-status-current-fg colour1 # Inversion des couleur pour l'onglet selectione | |
setw -g window-status-current-bg colour0 # | |
set-option -g history-limit 10000 # Permet de scroller 10k lignes | |
set -g history-limit 10000 # |
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
BUILD_DEPLOY_DIRECTORY="$HOME/dev/projects/app-build" | |
BUILD_DEPLOY_REMOTE=$(git config --get remote.origin.url) | |
BUILD_DIRECTORY="$HOME/dev/projects/app/www" # www or build | |
BUILD_COMMIT_MESSAGE=$(date +'%c') | |
R=$(tput setaf 1) | |
G=$(tput setaf 2) | |
Y=$(tput setaf 3) | |
NC=$(tput sgr0) |
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
<IfModule mod_rewrite.c > | |
RewriteEngine on | |
RewriteOptions inherit | |
# let's encrypt ssl | |
RewriteCond %{REQUEST_URI} !^/\.well-known/acme-challenge/.+$ | |
RewriteCond %{REQUEST_URI} !^/\.well-known/pki-validation/[A-F0-9]{32}\.txt(?:\ Comodo\ DCV)?$ | |
RewriteRule ^.well-known/acme-challenge - [L] | |
# redirect to no-www |