ref: rename updated hook to 'patched'

This commit is contained in:
Géry Debongnie
2019-04-09 10:37:53 +02:00
parent 370a92b67e
commit 6e0ef0fd5c
2 changed files with 17 additions and 17 deletions
+4 -4
View File
@@ -173,7 +173,7 @@ export class Component<
* turn will cause other calls to updated. So, we need to be particularly * turn will cause other calls to updated. So, we need to be particularly
* careful at avoiding endless cycles. * careful at avoiding endless cycles.
*/ */
updated() {} patched() {}
/** /**
* willUnmount is a hook that is called each time a component is detached from * willUnmount is a hook that is called each time a component is detached from
@@ -309,7 +309,7 @@ export class Component<
if (this.__widget__.isMounted) { if (this.__widget__.isMounted) {
await this.render(true); await this.render(true);
} }
this.updated(); this.patched();
} }
async updateProps( async updateProps(
@@ -341,7 +341,7 @@ export class Component<
if (this.__widget__.isStarted) { if (this.__widget__.isStarted) {
await this.render(); await this.render();
} }
this.updated(); this.patched();
} }
//-------------------------------------------------------------------------- //--------------------------------------------------------------------------
@@ -351,7 +351,7 @@ export class Component<
async _updateProps(nextProps: Props): Promise<void> { async _updateProps(nextProps: Props): Promise<void> {
this.props = nextProps; this.props = nextProps;
await this.render(); await this.render();
this.updated(); this.patched();
} }
_patch(vnode) { _patch(vnode) {
+13 -13
View File
@@ -387,13 +387,13 @@ describe("lifecycle hooks", () => {
]); ]);
}); });
test("updated hook is called after updateState", async () => { test("patched hook is called after updateState", async () => {
let n = 0; let n = 0;
class TestWidget extends Widget { class TestWidget extends Widget {
state = { a: 1 }; state = { a: 1 };
updated() { patched() {
n++; n++;
} }
} }
@@ -408,11 +408,11 @@ describe("lifecycle hooks", () => {
expect(n).toBe(1); expect(n).toBe(1);
}); });
test("updated hook is called after updateProps", async () => { test("patched hook is called after updateProps", async () => {
let n = 0; let n = 0;
class TestWidget extends Widget { class TestWidget extends Widget {
updated() { patched() {
n++; n++;
} }
} }
@@ -424,13 +424,13 @@ describe("lifecycle hooks", () => {
expect(n).toBe(1); expect(n).toBe(1);
}); });
test("updated hook is called after updateEnv", async () => { test("patched hook is called after updateEnv", async () => {
let n = 0; let n = 0;
class TestWidget extends Widget { class TestWidget extends Widget {
state = { a: 1 }; state = { a: 1 };
updated() { patched() {
n++; n++;
} }
} }
@@ -499,7 +499,7 @@ describe("lifecycle hooks", () => {
expect(destroyed).toBe(true); expect(destroyed).toBe(true);
}); });
test("willPatch/updated hook", async () => { test("willPatch/patched hook", async () => {
const steps: string[] = []; const steps: string[] = [];
class ParentWidget extends Widget { class ParentWidget extends Widget {
inlineTemplate = ` inlineTemplate = `
@@ -511,8 +511,8 @@ describe("lifecycle hooks", () => {
willPatch() { willPatch() {
steps.push("parent:willPatch"); steps.push("parent:willPatch");
} }
updated() { patched() {
steps.push("parent:updated"); steps.push("parent:patched");
} }
} }
@@ -520,8 +520,8 @@ describe("lifecycle hooks", () => {
willPatch() { willPatch() {
steps.push("child:willPatch"); steps.push("child:willPatch");
} }
updated() { patched() {
steps.push("child:updated"); steps.push("child:patched");
} }
} }
const widget = new ParentWidget(env); const widget = new ParentWidget(env);
@@ -532,9 +532,9 @@ describe("lifecycle hooks", () => {
// Not sure about this order. If you disagree, feel free to open an issue... // Not sure about this order. If you disagree, feel free to open an issue...
expect(steps).toEqual([ expect(steps).toEqual([
"child:willPatch", "child:willPatch",
"child:updated", "child:patched",
"parent:willPatch", "parent:willPatch",
"parent:updated" "parent:patched"
]); ]);
}); });
}); });