Functions for resolving polycons (polymorphic constructs) into specific constructs.
Name | Description |
---|---|
newInstance |
Creates a new instance of a polycon. |
register |
Adds a factory at given scope. |
import { Polycons } from 'polycons'
Polycons.newInstance(type: string, scope: IConstruct, id: string, args: any)
Creates a new instance of a polycon.
The polycon is resolved using the polycon factory that is registered nearest to it in the tree.
For example, if a construct tree has Root -> Parent -> MyPoly, and FactoryA is registered to Root while FactoryB is registered to Parent, then FactoryB will be used to resolve MyPoly.
- Type: string
The type identifier.
- Type: constructs.IConstruct
The construct scope.
- Type: string
The construct identifier.
- Type: any
The rest of the construct's arguments.
import { Polycons } from 'polycons'
Polycons.register(scope: IConstruct, factory: IPolyconFactory)
Adds a factory at given scope.
This factory will be used for resolving polycons under this scope into constructs.
- Type: constructs.IConstruct
- Type: IPolyconFactory
- Implemented By: IPolyconFactory
A factory that determines how to turn polycons into concrete constructs.
Name | Description |
---|---|
resolve |
Resolve the parameters needed for creating a specific polycon into a concrete construct. |
public resolve(type: string, scope: IConstruct, id: string, args: any): IConstruct
Resolve the parameters needed for creating a specific polycon into a concrete construct.
- Type: string
The type identifier.
- Type: constructs.IConstruct
The construct scope.
- Type: string
The construct identifier.
- Type: any
The rest of the construct's arguments.