API referenceEngine
factory
Import from bear/engine/factory.
Type Aliases
Factory
type Factory<S, P> = (situational) => BearElement<P>;Defined in: bear/engine/factory.ts:8
A factory produces a BearElement from situational props. S = what the consuming assembly supplies at render time; P = the part's props. A factory for a part the assembly doesn't know states neither.
Type Parameters
Parameters
| Parameter | Type |
|---|---|
situational | S & ElementProps |
Returns
BearElement<P>
Functions
factory()
function factory<P>(def, defaults): Factory<Partial<P>, P>;Defined in: bear/engine/factory.ts:25
Create a factory from a PartDef with default props.
Returns a function that merges situational props (from the assembly) over the defaults, then calls the PartDef to produce a BearElement.
const osb716 = factory(OSB, { category: "7/16in" });
// Later, an assembly calls:
osb716({ face: someSurface, panelRegion: region })Type Parameters
Parameters
| Parameter | Type |
|---|---|
def | PartDef<P> |
defaults | Partial<P> |
Returns
Factory<Partial<P>, P>