mobx 6.13.7 → 6.15.0

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.
@@ -5,7 +5,7 @@ export interface IKeyValueMap<V = any> {
5
5
  export type IMapEntry<K = any, V = any> = [K, V];
6
6
  export type IReadonlyMapEntry<K = any, V = any> = readonly [K, V];
7
7
  export type IMapEntries<K = any, V = any> = IMapEntry<K, V>[];
8
- export type IReadonlyMapEntries<K = any, V = any> = IReadonlyMapEntry<K, V>[];
8
+ export type IReadonlyMapEntries<K = any, V = any> = readonly IReadonlyMapEntry<K, V>[];
9
9
  export type IMapDidChange<K = any, V = any> = {
10
10
  observableKind: "map";
11
11
  debugObjectName: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx",
3
- "version": "6.13.7",
3
+ "version": "6.15.0",
4
4
  "description": "Simple, scalable state management.",
5
5
  "source": "src/mobx.ts",
6
6
  "main": "dist/index.js",
@@ -3,6 +3,9 @@ import {
3
3
  IEqualsComparer,
4
4
  IObservableArray,
5
5
  IObservableMapInitialValues,
6
+ IMapEntries,
7
+ IReadonlyMapEntries,
8
+ IKeyValueMap,
6
9
  IObservableSetInitialValues,
7
10
  IObservableValue,
8
11
  ObservableMap,
@@ -151,6 +154,24 @@ export interface IObservableValueFactory {
151
154
  <T>(value?: T, options?: CreateObservableOptions): IObservableValue<T | undefined>
152
155
  }
153
156
 
157
+ export interface IObservableMapFactory {
158
+ <K = any, V = any>(): ObservableMap<K, V>
159
+ <K, V>(initialValues?: IMapEntries<K, V>, options?: CreateObservableOptions): ObservableMap<
160
+ K,
161
+ V
162
+ >
163
+ <K, V>(
164
+ initialValues?: IReadonlyMapEntries<K, V>,
165
+ options?: CreateObservableOptions
166
+ ): ObservableMap<K, V>
167
+ <K, V>(initialValues?: IKeyValueMap<V>, options?: CreateObservableOptions): ObservableMap<K, V>
168
+ <K, V>(initialValues?: Map<K, V>, options?: CreateObservableOptions): ObservableMap<K, V>
169
+ <K = any, V = any>(initialValues: undefined, options?: CreateObservableOptions): ObservableMap<
170
+ K,
171
+ V
172
+ >
173
+ }
174
+
154
175
  export interface IObservableFactory
155
176
  extends Annotation,
156
177
  PropertyDecorator,
@@ -172,10 +193,7 @@ export interface IObservableFactory
172
193
  initialValues?: IObservableSetInitialValues<T>,
173
194
  options?: CreateObservableOptions
174
195
  ) => ObservableSet<T>
175
- map: <K = any, V = any>(
176
- initialValues?: IObservableMapInitialValues<K, V>,
177
- options?: CreateObservableOptions
178
- ) => ObservableMap<K, V>
196
+ map: IObservableMapFactory
179
197
  object: <T = any>(
180
198
  props: T,
181
199
  decorators?: AnnotationsMap<T, never>,
@@ -240,6 +240,10 @@ export class Reaction implements IDerivation, IReactionPublic {
240
240
  abortSignal?.addEventListener?.("abort", dispose)
241
241
  dispose[$mobx] = this
242
242
 
243
+ if ("dispose" in Symbol && typeof Symbol.dispose === "symbol") {
244
+ dispose[Symbol.dispose] = dispose
245
+ }
246
+
243
247
  return dispose
244
248
  }
245
249
 
@@ -10,7 +10,8 @@ import {
10
10
  autoAction,
11
11
  isGenerator,
12
12
  MakeResult,
13
- die
13
+ die,
14
+ isAction
14
15
  } from "../internal"
15
16
 
16
17
  const AUTO = "true"
@@ -40,7 +41,9 @@ function make_(
40
41
  // lone setter -> action setter
41
42
  if (descriptor.set) {
42
43
  // TODO make action applicable to setter and delegate to action.make_
43
- const set = createAction(key.toString(), descriptor.set) as (v: any) => void
44
+ const set = isAction(descriptor.set)
45
+ ? descriptor.set // See #4553
46
+ : (createAction(key.toString(), descriptor.set) as (v: any) => void)
44
47
  // own
45
48
  if (source === adm.target_) {
46
49
  return adm.defineProperty_(key, {
@@ -46,7 +46,7 @@ export interface IKeyValueMap<V = any> {
46
46
  export type IMapEntry<K = any, V = any> = [K, V]
47
47
  export type IReadonlyMapEntry<K = any, V = any> = readonly [K, V]
48
48
  export type IMapEntries<K = any, V = any> = IMapEntry<K, V>[]
49
- export type IReadonlyMapEntries<K = any, V = any> = IReadonlyMapEntry<K, V>[]
49
+ export type IReadonlyMapEntries<K = any, V = any> = readonly IReadonlyMapEntry<K, V>[]
50
50
 
51
51
  export type IMapDidChange<K = any, V = any> = { observableKind: "map"; debugObjectName: string } & (
52
52
  | {
@@ -83,7 +83,7 @@ export class ObservableValue<T>
83
83
  object: this,
84
84
  observableKind: "value",
85
85
  debugObjectName: this.name_,
86
- newValue: "" + this.value_
86
+ newValue: "" + this.value_?.toString()
87
87
  })
88
88
  }
89
89
  }