@adobe/lit-mobx
Advanced tools
Comparing version 0.0.3 to 0.0.4
@@ -15,3 +15,2 @@ /* | ||
const cachedRequestUpdate = Symbol('LitMobxRequestUpdate'); | ||
const cachedPerformUpdate = Symbol('LitMobxPerformUpdate'); | ||
/** | ||
@@ -28,8 +27,9 @@ * A class mixin which can be applied to lit-element's | ||
export function MobxReactionUpdate(constructor) { | ||
var _a, _b, _c; | ||
return _c = class MobxReactingElement extends constructor { | ||
var _a, _b; | ||
return _b = class MobxReactingElement extends constructor { | ||
constructor() { | ||
super(...arguments); | ||
this[_a] = () => this.requestUpdate(); | ||
this[_b] = () => super.performUpdate(); | ||
this[_a] = () => { | ||
this.requestUpdate(); | ||
}; | ||
} | ||
@@ -52,8 +52,8 @@ connectedCallback() { | ||
} | ||
performUpdate() { | ||
update(changedProperties) { | ||
if (this[reaction]) { | ||
this[reaction].track(this[cachedPerformUpdate]); | ||
this[reaction].track(super.update.bind(this, changedProperties)); | ||
} | ||
else { | ||
super.performUpdate(); | ||
super.update(changedProperties); | ||
} | ||
@@ -63,5 +63,4 @@ } | ||
_a = cachedRequestUpdate, | ||
_b = cachedPerformUpdate, | ||
_c; | ||
_b; | ||
} | ||
//# sourceMappingURL=mixin.js.map |
{ | ||
"name": "@adobe/lit-mobx", | ||
"version": "0.0.3", | ||
"version": "0.0.4", | ||
"description": "Integrating mobx with lit-element!", | ||
@@ -42,7 +42,7 @@ "license": "Apache-2.0", | ||
"devDependencies": { | ||
"@open-wc/testing": "^2.5.8", | ||
"@open-wc/testing-karma": "^3.3.8", | ||
"@open-wc/testing": "^2.5.13", | ||
"@open-wc/testing-karma": "^3.3.15", | ||
"deepmerge": "^4.2.2", | ||
"es-dev-server": "^1.45.2", | ||
"lit-element": "^2.3.0", | ||
"es-dev-server": "^1.46.5", | ||
"lit-element": "^2.0.0", | ||
"mobx": "^5.15.4", | ||
@@ -49,0 +49,0 @@ "typescript": "^3.8.3" |
@@ -15,3 +15,2 @@ /* | ||
const cachedRequestUpdate = Symbol('LitMobxRequestUpdate'); | ||
const cachedPerformUpdate = Symbol('LitMobxPerformUpdate'); | ||
/** | ||
@@ -28,8 +27,9 @@ * A class mixin which can be applied to lit-element's | ||
export function MobxReactionUpdate(constructor) { | ||
var _a, _b, _c; | ||
return _c = class MobxReactingElement extends constructor { | ||
var _a, _b; | ||
return _b = class MobxReactingElement extends constructor { | ||
constructor() { | ||
super(...arguments); | ||
this[_a] = () => this.requestUpdate(); | ||
this[_b] = () => super.performUpdate(); | ||
this[_a] = () => { | ||
this.requestUpdate(); | ||
}; | ||
} | ||
@@ -52,8 +52,8 @@ connectedCallback() { | ||
} | ||
performUpdate() { | ||
update(changedProperties) { | ||
if (this[reaction]) { | ||
this[reaction].track(this[cachedPerformUpdate]); | ||
this[reaction].track(super.update.bind(this, changedProperties)); | ||
} | ||
else { | ||
super.performUpdate(); | ||
super.update(changedProperties); | ||
} | ||
@@ -63,5 +63,4 @@ } | ||
_a = cachedRequestUpdate, | ||
_b = cachedPerformUpdate, | ||
_c; | ||
_b; | ||
} | ||
//# sourceMappingURL=mixin.js.map |
@@ -13,3 +13,3 @@ /* | ||
import { UpdatingElement } from 'lit-element'; | ||
import { UpdatingElement, PropertyValues } from 'lit-element'; | ||
import { Reaction } from 'mobx'; | ||
@@ -19,3 +19,2 @@ | ||
const cachedRequestUpdate = Symbol('LitMobxRequestUpdate'); | ||
const cachedPerformUpdate = Symbol('LitMobxPerformUpdate'); | ||
@@ -41,4 +40,5 @@ type UpdatingElementConstructor = new (...args: any[]) => UpdatingElement; | ||
private [cachedRequestUpdate] = () => this.requestUpdate(); | ||
private [cachedPerformUpdate] = () => super.performUpdate(); | ||
private [cachedRequestUpdate] = () => { | ||
this.requestUpdate(); | ||
}; | ||
@@ -65,7 +65,9 @@ public connectedCallback(): void { | ||
protected performUpdate(): void { | ||
protected update(changedProperties: PropertyValues): void { | ||
if (this[reaction]) { | ||
this[reaction]!.track(this[cachedPerformUpdate]!); | ||
this[reaction]!.track( | ||
super.update.bind(this, changedProperties) | ||
); | ||
} else { | ||
super.performUpdate(); | ||
super.update(changedProperties); | ||
} | ||
@@ -72,0 +74,0 @@ } |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
74235