Comparing version 0.22.0 to 0.23.0
@@ -55,11 +55,11 @@ import { ComposibleValidatable, Validator } from './types'; | ||
*/ | ||
protected _onWillChange: (config: { | ||
protected _onDidChange: (config: { | ||
newValue: TValue; | ||
oldValue: TValue; | ||
}) => any; | ||
onWillChange: (handler: (config: { | ||
onDidChange: (handler: (config: { | ||
newValue: TValue; | ||
oldValue: TValue; | ||
}) => any) => this; | ||
protected executeOnWillChange: (config: { | ||
protected executeOnDidChange: (config: { | ||
newValue: TValue; | ||
@@ -66,0 +66,0 @@ oldValue: TValue; |
@@ -74,8 +74,8 @@ "use strict"; | ||
}; | ||
this.onWillChange = function (handler) { | ||
_this._onWillChange = handler; | ||
this.onDidChange = function (handler) { | ||
_this._onDidChange = handler; | ||
return _this; | ||
}; | ||
this.executeOnWillChange = function (config) { | ||
_this._onWillChange && _this._onWillChange(config); | ||
this.executeOnDidChange = function (config) { | ||
_this._onDidChange && _this._onDidChange(config); | ||
}; | ||
@@ -93,6 +93,8 @@ this.setAutoValidationDebouncedMs = function (milliseconds) { | ||
_this.preventNextQueuedValidation = false; | ||
// Call on will change if any | ||
_this.executeOnWillChange({ newValue: value, oldValue: _this.value }); | ||
// Store local old value for onDidChange | ||
var oldValue = _this.value; | ||
// Immediately set for local ui binding | ||
_this.value = value; | ||
// Call on did change if any | ||
_this.executeOnDidChange({ newValue: value, oldValue: oldValue }); | ||
_this.dirty = true; | ||
@@ -264,6 +266,6 @@ _this.executeOnUpdate(); | ||
mobx_1.action | ||
], FieldState.prototype, "onWillChange", void 0); | ||
], FieldState.prototype, "onDidChange", void 0); | ||
__decorate([ | ||
mobx_1.action | ||
], FieldState.prototype, "executeOnWillChange", void 0); | ||
], FieldState.prototype, "executeOnDidChange", void 0); | ||
__decorate([ | ||
@@ -270,0 +272,0 @@ mobx_1.action |
{ | ||
"name": "formstate", | ||
"version": "0.22.0", | ||
"version": "0.23.0", | ||
"description": "Painless and simple MobX form management", | ||
@@ -5,0 +5,0 @@ "main": "./lib/index.js", |
@@ -93,9 +93,9 @@ import { observable, action, computed, runInAction } from 'mobx'; | ||
*/ | ||
protected _onWillChange: (config: { newValue: TValue, oldValue: TValue }) => any; | ||
@action public onWillChange = (handler: (config: { newValue: TValue, oldValue: TValue }) => any) => { | ||
this._onWillChange = handler; | ||
protected _onDidChange: (config: { newValue: TValue, oldValue: TValue }) => any; | ||
@action public onDidChange = (handler: (config: { newValue: TValue, oldValue: TValue }) => any) => { | ||
this._onDidChange = handler; | ||
return this; | ||
} | ||
@action protected executeOnWillChange = (config: { newValue: TValue, oldValue: TValue }) => { | ||
this._onWillChange && this._onWillChange(config); | ||
@action protected executeOnDidChange = (config: { newValue: TValue, oldValue: TValue }) => { | ||
this._onDidChange && this._onDidChange(config); | ||
} | ||
@@ -113,11 +113,15 @@ | ||
/** On change on the component side */ | ||
@action onChange = (value: TValue) => { | ||
@action | ||
onChange = (value: TValue) => { | ||
// no long prevent any debounced validation request | ||
this.preventNextQueuedValidation = false; | ||
// Call on will change if any | ||
this.executeOnWillChange({ newValue: value, oldValue: this.value }); | ||
// Store local old value for onDidChange | ||
const oldValue = this.value; | ||
// Immediately set for local ui binding | ||
this.value = value; | ||
// Call on did change if any | ||
this.executeOnDidChange({ newValue: value, oldValue }); | ||
this.dirty = true; | ||
@@ -124,0 +128,0 @@ this.executeOnUpdate(); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
74797
2002