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

Commitb8f35f4

Browse files
authored
U/jarmit/fix mutator name (#141)
* Setting the name of the mutator instead of the name of the creating function* 4.2.2* fix tests* Actually fix tests* rename
1 parente964670 commitb8f35f4

File tree

3 files changed

+9
-5
lines changed

3 files changed

+9
-5
lines changed

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name":"satcheljs",
3-
"version":"4.2.1",
3+
"version":"4.2.2",
44
"description":"Store implementation for functional reactive flux.",
55
"lint-staged": {
66
"*.{ts,tsx}": [

‎src/mutator.ts‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,10 @@ export default function mutator<TAction extends ActionMessage, TReturn>(
1717
}
1818

1919
// Wrap the callback in a MobX action so it can modify the store
20-
letwrappedTarget=action(getPrivateActionType(actionCreator),(actionMessage:TAction)=>{
20+
constactionType=getPrivateActionType(actionCreator);
21+
letwrappedTarget=action(actionType,(actionMessage:TAction)=>{
2122
try{
22-
getGlobalContext().currentMutator=actionCreator.name;
23+
getGlobalContext().currentMutator=actionType;
2324
target(actionMessage);
2425
}finally{
2526
getGlobalContext().currentMutator=null;

‎test/mutatorTests.ts‎

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,12 @@ describe('mutator', () => {
6464

6565
it('sets the currentMutator to actionMessage type for the duration of the mutator callback',()=>{
6666
// Arrange
67-
letactionCreator:any={__SATCHELJS_ACTION_ID:'testAction',name:'testName'};
67+
letactionCreator:any={
68+
__SATCHELJS_ACTION_ID:'testAction',
69+
__SATCHELJS_ACTION_TYPE:'testActionType',
70+
};
6871
letcallback=()=>{
69-
expect(mockGlobalContext.currentMutator).toBe('testName');
72+
expect(mockGlobalContext.currentMutator).toBe('testActionType');
7073
};
7174
mutator(actionCreator,callback);
7275

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp