mobx 6.3.12 → 6.3.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx",
3
- "version": "6.3.12",
3
+ "version": "6.3.13",
4
4
  "description": "Simple, scalable state management.",
5
5
  "source": "src/mobx.ts",
6
6
  "main": "dist/index.js",
@@ -7,7 +7,8 @@ import {
7
7
  isFlow,
8
8
  isFunction,
9
9
  globalState,
10
- MakeResult
10
+ MakeResult,
11
+ hasProp
11
12
  } from "../internal"
12
13
 
13
14
  export function createFlowAnnotation(name: string, options?: object): Annotation {
@@ -33,7 +34,7 @@ function make_(
33
34
  }
34
35
  // prototype
35
36
  // bound - must annotate protos to support super.flow()
36
- if (this.options_?.bound && !isFlow(adm.target_[key])) {
37
+ if (this.options_?.bound && (!hasProp(adm.target_, key) || !isFlow(adm.target_[key]))) {
37
38
  if (this.extend_(adm, key, descriptor, false) === null) return MakeResult.Cancel
38
39
  }
39
40
  if (isFlow(descriptor.value)) {
@@ -81,11 +82,18 @@ function createFlowDescriptor(
81
82
  ): PropertyDescriptor {
82
83
  assertFlowDescriptor(adm, annotation, key, descriptor)
83
84
  let { value } = descriptor
85
+ // In case of flow.bound, the descriptor can be from already annotated prototype
86
+ if (!isFlow(value)) {
87
+ value = flow(value)
88
+ }
84
89
  if (bound) {
90
+ // We do not keep original function around, so we bind the existing flow
85
91
  value = value.bind(adm.proxy_ ?? adm.target_)
92
+ // This is normally set by `flow`, but `bind` returns new function...
93
+ value.isMobXFlow = true
86
94
  }
87
95
  return {
88
- value: flow(value),
96
+ value,
89
97
  // Non-configurable for classes
90
98
  // prevents accidental field redefinition in subclass
91
99
  configurable: safeDescriptors ? adm.isPlainObject_ : true,