ObjectPoolFactory
class ObjectPoolFactory
Factory for creating pools of objects with default constructors. It will store the pool of a given type and reuse it on further builds.
```js
import { ObjectPool, ObjectPoolFactory } from '@pixi-essentials/object-pool';
class AABB {}
const opool: ObjectPool<AABB> = ObjectPoolFactory.build(AABB) as ObjectPool<AABB>;
const temp = opool.borrowObject();
// do something
opool.returnObject(temp);
```
Constructor
new ObjectPoolFactory() → {}
Summary
Methods from ObjectPoolFactory
Public Methods
static build(classConstructor: { new (): T }) → {ObjectPool<T>}
Builds an object-pool for objects constructed from the given class with a default constructor. If an object pool for that class was already created, an existing instance is returned.
Name | Type | Description |
---|---|---|
classConstructor | { new (): T } |
Type | Description |
---|---|
ObjectPool<T> |
static buildFunctional(factoryFunction: () => T) → {ObjectPool<T>}
Builds an object-pool for objects built using a factory function. The factory function's context will be the object-pool.
These types of pools are not cached and should only be used on internal data structures.
Name | Type | Description |
---|---|---|
factoryFunction | () => T |
Type | Description |
---|---|
ObjectPool<T> |