#Using a Builder with method depending on a passed parameter

10 messages · Page 1 of 1 (latest)

misty stratus
#

Is it possible to use the Builder Pattern so that the following would be possible?

const house1 = new HouseBuilder(HouseType.BASIC).setBasicStyle().build();

const house2 = new HouseBuilder(HouseType.ADVANCED).setAdvancedStyle().build();

Is this somehow possible where depending on the passed parameter only the specific method is callable, for instance a Basic House should not be able to call setAdvancedStyle() and so on...

Any help would be appreciated. Is there an advanced builder pattern or something better for this?

crisp timber
#

have you looked into the Beta features?

misty stratus
crisp timber
#

just that there are a number of new features that from what I read just might help you.

one of the new features that I used was to create custom types

#

I found all my answers to every issue from reading the GITHUB discussions and issues

misty stratus
#

Yeah figured. Sadly I am stuck with TS <5.0

crisp timber
#

i played with this