Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit24d040a

Browse files
author
mheiber
authored
Merge pull request#10 from mheiber/no-new-state-on-unhandled-action
When the action is unhandled, return same state
2 parents8d084d0 +4c91cef commit24d040a

File tree

2 files changed

+7
-0
lines changed

2 files changed

+7
-0
lines changed

‎index.js‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ var createMachine = function(reducersObject) {
88
thrownewError('reducersObject missing reducer for status '+status)
99
}
1010
constnextState=reducer(state,action)
11+
if(nextState===state){
12+
returnstate
13+
}
1114
returnObject.assign({},nextState,{'status':nextState.status||status})
1215
}
1316
}

‎test.js‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,10 @@ test('should transition between states', t => {
6868
status:'INIT',
6969
},'Should set initial status to "INIT"')
7070

71+
action('DUMMY AGAIN')
72+
73+
t.equals(state,prevState,'Should not change the state when an action is unhandled')
74+
7175
action('FETCH_USERS_RESPONSE',{users})
7276
expectState(prevState,'Should ignore messages when not handled by current status')
7377

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp