Skip to content

Commit ffe9594

Browse files
fix(overmind): fix issue with bound proxy on statemachines
1 parent 3336da0 commit ffe9594

File tree

4 files changed

+4
-18
lines changed

4 files changed

+4
-18
lines changed

packages/node_modules/overmind/src/index.ts

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,10 @@ import {
4343
IOnInitialize,
4444
IOperator,
4545
IReaction,
46-
IState,
4746
} from './types'
4847
import {
4948
EXECUTION,
5049
IS_OPERATOR,
51-
IS_PROXY_BOUND_FUNCTION,
5250
IS_TEST,
5351
MODE_DEFAULT,
5452
MODE_SSR,
@@ -394,16 +392,14 @@ export class Overmind<ThisConfig extends IConfiguration>
394392
{
395393
devmode,
396394
delimiter: this.delimiter,
397-
onSetFunction: (proxy, tree, path, target, prop, func) => {
395+
onSetFunction: (tree, path, target, prop, func) => {
398396
if (func[IS_DERIVED_CONSTRUCTOR]) {
399397
return new Derived(func) as any
400398
}
401399

402-
func = func.bind(proxy)
403-
func[IS_PROXY_BOUND_FUNCTION] = true
404400
return func
405401
},
406-
onGetFunction: (proxy, tree, path, target, prop) => {
402+
onGetFunction: (tree, path, target, prop) => {
407403
let func = target[prop]
408404

409405
if (func[IS_DERIVED]) {
@@ -417,13 +413,6 @@ export class Overmind<ThisConfig extends IConfiguration>
417413
return derived(eventHub, tree, proxyStateTree, path.split(this.delimiter))
418414
}
419415

420-
if (func[IS_PROXY_BOUND_FUNCTION]) {
421-
return func
422-
}
423-
424-
func = func.bind(proxy)
425-
func[IS_PROXY_BOUND_FUNCTION] = true
426-
target[prop] = func
427416
return func
428417
},
429418
onGetter: devmode

packages/node_modules/overmind/src/utils.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ export const IS_TEST = process.env.NODE_ENV === 'test'
55
export const IS_OPERATOR = Symbol('operator')
66
export const ORIGINAL_ACTIONS = Symbol('origina_actions')
77
export const EXECUTION = Symbol('execution')
8-
export const IS_PROXY_BOUND_FUNCTION = Symbol('is_proxy_bound_function')
98

109
export const MODE_DEFAULT = Symbol('MODE_DEFAULT')
1110
export const MODE_TEST = Symbol('MODE_TEST')

packages/node_modules/proxy-state-tree/src/Proxyfier.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,14 +261,13 @@ export class Proxifier {
261261
if (typeof targetValue === 'function') {
262262
if (proxifier.tree.master.options.onGetFunction) {
263263
return proxifier.tree.master.options.onGetFunction(
264-
proxy,
265264
trackingTree || proxifier.tree,
266265
nestedPath,
267266
target,
268267
prop
269268
)
270269
}
271-
return isClass(target) ? (...args) => targetValue.call(proxy, ...args) : targetValue.call(target, proxifier.tree, nestedPath)
270+
return isClass(target) ? targetValue : targetValue.call(target, proxifier.tree, nestedPath)
272271
} else {
273272
currentTree.trackPathListeners.forEach((cb) => cb(nestedPath))
274273
trackingTree && trackingTree.proxifier.trackPath(nestedPath)
@@ -299,7 +298,6 @@ export class Proxifier {
299298

300299
if (typeof value === 'function' && proxifier.tree.master.options.onSetFunction) {
301300
value = proxifier.tree.master.options.onSetFunction(
302-
proxy,
303301
proxifier.getTrackingTree() || proxifier.tree,
304302
nestedPath,
305303
target,

packages/node_modules/proxy-state-tree/src/index.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -755,7 +755,7 @@ describe('FUNCTIONS', () => {
755755
},
756756
}
757757
const tree = new ProxyStateTree(state, {
758-
onGetFunction: (proxy, proxyStateTree, path, target, prop) =>
758+
onGetFunction: (proxyStateTree, path, target, prop) =>
759759
target[prop]('foo', proxyStateTree, path),
760760
})
761761

0 commit comments

Comments
 (0)