From 1cd11326a6e57d2802d2c21f5ff3f1a31ad4f2d7 Mon Sep 17 00:00:00 2001 From: Godfrey Chan Date: Sat, 25 Mar 2017 16:06:36 -0700 Subject: [PATCH] Fix code example --- text/0000-custom-components.md | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/text/0000-custom-components.md b/text/0000-custom-components.md index e0f953dc04..af714360a2 100644 --- a/text/0000-custom-components.md +++ b/text/0000-custom-components.md @@ -771,6 +771,7 @@ Given the following `ComponentDefinition`s: // component-manager:pooled interface PoolEntry { + name: string; instance: Ember.Component; expiresAt: number; } @@ -788,7 +789,8 @@ class ComponentPool { } } - checkin(name: string, entry: PoolEntry) { + checkin(entry: PoolEntry) { + let { name } = entry; let pool = this.pools[name]; if (!pool) { @@ -827,16 +829,17 @@ class PooledManager extends ComponentManager { private pool = new ComponentPool(); create({ metadata }: ComponentDefinition, args: ComponentArguments) { - let entry = pool.checkout(metadata.class); + let name = metadata.class; + let entry = pool.checkout(name); let instance, isRecycled; if (entry) { instance = entry.instance; isRecycled = true; } else { - instance = getOwner(this).lookup(`component:${metadata.class}`); + instance = getOwner(this).lookup(`component:${name}`); isRecycled = false; - entry = { instace, expiresAt: NaN }; + entry = { name, instace, expiresAt: NaN }; } instance.setProperties(args.named); @@ -849,7 +852,7 @@ class PooledManager extends ComponentManager { instance.didReceiveAttrs(); - return instance; + return entry; } getContext({ instance }: PoolEntry): Ember.Component { @@ -867,7 +870,7 @@ class PooledManager extends ComponentManager { } destroy(entry: PoolEntry) { - this.pool.checkin(instance); + this.pool.checkin(entry); } } ```