Skip to content

Commit 9ce985f

Browse files
committed
Reproduced and fixed mobxjs#1376
1 parent 4e6f084 commit 9ce985f

2 files changed

Lines changed: 15 additions & 1 deletion

File tree

src/api/action.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,11 @@ export var action: IActionFactory = function action(arg1, arg2?, arg3?, arg4?):
5555
// @action fn() {}
5656
if (arg4 === true) {
5757
// apply to instance immediately
58-
arg1[arg2] = createAction(name, arg3.value)
58+
arg1[arg2] = createAction(arg1.name || arg2, arg3.value)
5959
} else {
6060
return namedActionDecorator(arg2).apply(null, arguments)
6161
}
62+
toString
6263
} as any
6364

6465
action.bound = boundActionDecorator as any

test/base/action.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -455,3 +455,16 @@ test("bound actions bind", () => {
455455
d()
456456
d2()
457457
})
458+
459+
test("Fix #1367", () => {
460+
const x = mobx.extendObservable(
461+
{},
462+
{
463+
method() {}
464+
},
465+
{
466+
method: mobx.action
467+
}
468+
)
469+
expect(mobx.isAction(x.method)).toBe(true)
470+
})

0 commit comments

Comments
 (0)