From 6e0ef0fd5c2d6e3ff8adf54df5ec271317488b79 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?G=C3=A9ry=20Debongnie?= Date: Tue, 9 Apr 2019 10:37:53 +0200 Subject: [PATCH] ref: rename updated hook to 'patched' --- src/component.ts | 8 ++++---- tests/component.test.ts | 26 +++++++++++++------------- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/component.ts b/src/component.ts index 687694c2..ffb16e69 100644 --- a/src/component.ts +++ b/src/component.ts @@ -173,7 +173,7 @@ export class Component< * turn will cause other calls to updated. So, we need to be particularly * careful at avoiding endless cycles. */ - updated() {} + patched() {} /** * 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) { await this.render(true); } - this.updated(); + this.patched(); } async updateProps( @@ -341,7 +341,7 @@ export class Component< if (this.__widget__.isStarted) { await this.render(); } - this.updated(); + this.patched(); } //-------------------------------------------------------------------------- @@ -351,7 +351,7 @@ export class Component< async _updateProps(nextProps: Props): Promise { this.props = nextProps; await this.render(); - this.updated(); + this.patched(); } _patch(vnode) { diff --git a/tests/component.test.ts b/tests/component.test.ts index c7b6535f..c0455b58 100644 --- a/tests/component.test.ts +++ b/tests/component.test.ts @@ -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; class TestWidget extends Widget { state = { a: 1 }; - updated() { + patched() { n++; } } @@ -408,11 +408,11 @@ describe("lifecycle hooks", () => { expect(n).toBe(1); }); - test("updated hook is called after updateProps", async () => { + test("patched hook is called after updateProps", async () => { let n = 0; class TestWidget extends Widget { - updated() { + patched() { n++; } } @@ -424,13 +424,13 @@ describe("lifecycle hooks", () => { expect(n).toBe(1); }); - test("updated hook is called after updateEnv", async () => { + test("patched hook is called after updateEnv", async () => { let n = 0; class TestWidget extends Widget { state = { a: 1 }; - updated() { + patched() { n++; } } @@ -499,7 +499,7 @@ describe("lifecycle hooks", () => { expect(destroyed).toBe(true); }); - test("willPatch/updated hook", async () => { + test("willPatch/patched hook", async () => { const steps: string[] = []; class ParentWidget extends Widget { inlineTemplate = ` @@ -511,8 +511,8 @@ describe("lifecycle hooks", () => { willPatch() { steps.push("parent:willPatch"); } - updated() { - steps.push("parent:updated"); + patched() { + steps.push("parent:patched"); } } @@ -520,8 +520,8 @@ describe("lifecycle hooks", () => { willPatch() { steps.push("child:willPatch"); } - updated() { - steps.push("child:updated"); + patched() { + steps.push("child:patched"); } } 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... expect(steps).toEqual([ "child:willPatch", - "child:updated", + "child:patched", "parent:willPatch", - "parent:updated" + "parent:patched" ]); }); });