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
* 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<void> {
this.props = nextProps;
await this.render();
this.updated();
this.patched();
}
_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;
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"
]);
});
});