Skip to content

Commit

Permalink
Fix code example
Browse files Browse the repository at this point in the history
  • Loading branch information
chancancode authored Mar 25, 2017
1 parent 786ef16 commit 1cd1132
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions text/0000-custom-components.md
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ Given the following `ComponentDefinition`s:
// component-manager:pooled

interface PoolEntry {
name: string;
instance: Ember.Component;
expiresAt: number;
}
Expand All @@ -788,7 +789,8 @@ class ComponentPool {
}
}

checkin(name: string, entry: PoolEntry) {
checkin(entry: PoolEntry) {
let { name } = entry;
let pool = this.pools[name];

if (!pool) {
Expand Down Expand Up @@ -827,16 +829,17 @@ class PooledManager extends ComponentManager<PoolEntry> {
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);
Expand All @@ -849,7 +852,7 @@ class PooledManager extends ComponentManager<PoolEntry> {

instance.didReceiveAttrs();

return instance;
return entry;
}

getContext({ instance }: PoolEntry): Ember.Component {
Expand All @@ -867,7 +870,7 @@ class PooledManager extends ComponentManager<PoolEntry> {
}

destroy(entry: PoolEntry) {
this.pool.checkin(instance);
this.pool.checkin(entry);
}
}
```
Expand Down

0 comments on commit 1cd1132

Please sign in to comment.