Skip to content
This repository has been archived by the owner on Jul 16, 2023. It is now read-only.

Latest commit

 

History

History
153 lines (81 loc) · 3.78 KB

API.md

File metadata and controls

153 lines (81 loc) · 3.78 KB

API Reference

Classes

Polycons

Functions for resolving polycons (polymorphic constructs) into specific constructs.

Static Functions

Name Description
newInstance Creates a new instance of a polycon.
register Adds a factory at given scope.

newInstance
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.

typeRequired
  • Type: string

The type identifier.


scopeRequired
  • Type: constructs.IConstruct

The construct scope.


idRequired
  • Type: string

The construct identifier.


argsRequired
  • Type: any

The rest of the construct's arguments.


register
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.

scopeRequired
  • Type: constructs.IConstruct

factoryRequired

Protocols

IPolyconFactory

A factory that determines how to turn polycons into concrete constructs.

Methods

Name Description
resolve Resolve the parameters needed for creating a specific polycon into a concrete construct.

resolve
public resolve(type: string, scope: IConstruct, id: string, args: any): IConstruct

Resolve the parameters needed for creating a specific polycon into a concrete construct.

typeRequired
  • Type: string

The type identifier.


scopeRequired
  • Type: constructs.IConstruct

The construct scope.


idRequired
  • Type: string

The construct identifier.


argsRequired
  • Type: any

The rest of the construct's arguments.