Skip to content

Commit

Permalink
Merge pull request #1 from RafaelFontes/master
Browse files Browse the repository at this point in the history
Default value for state
  • Loading branch information
rikbruil committed Jul 18, 2017
2 parents a4dd65f + a239e96 commit 9a87ac9
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/Reducer/ComposedReducer.php
Expand Up @@ -51,7 +51,8 @@ public function addReducer($key, callable $reducer)
public function reduce($state, array $action)
{
foreach ($this->reducers as $key => $reducer) {
$state[$key] = $reducer($state[$key], $action);
$currentState = isset($state[$key]) ? $state[$key] : null;
$state[$key] = $reducer($currentState, $action);
}

return $state;
Expand Down

0 comments on commit 9a87ac9

Please sign in to comment.