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() → {}

Public Methods


build ObjectPoolFactory.ts:31
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.

Parameters:
Name Type Description
classConstructor { new (): T }
Returns:
Type Description
ObjectPool<T>
buildFunctional ObjectPoolFactory.ts:59
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.

Parameters:
Name Type Description
factoryFunction () => T
Returns:
Type Description
ObjectPool<T>

Powered by webdoc!