-
Couldn't load subscription status.
- Fork 54
Closed
Labels
enhancementNew feature or requestNew feature or request
Description
What is Mixin
Along with traditional OO hierarchies, another popular way of building up classes from reusable components is to build them by combining simpler partial classes. You may be familiar with the idea of mixins or traits for languages like Scala, and the pattern has also reached some popularity in the JavaScript community.
— https://www.typescriptlang.org/docs/handbook/mixins.html
Mixin is a great decouple and design pattern to split the puppet class logic into different files.
Wechaty Puppet Mixins
- We will have a
PuppetSkeltonas the base abstract class for all Mixins, it- extends the
PuppetEventEmitterfor adding the listener typings - has the least components to support other mixins
- extends the
- All functionalities will be added by mixin, for example:
CacheMixinforpuppet.cacherelated codesWatchdogMixinforpuppet.watchdogrelated codesMemoryMixinforpuppet.memoryrelated codesMessageMixin,ContactMixin,RoomMixin, etc to add related puppet abstract APIs
- All mixins need to implement a
start()andstop()and callsuper.start()andsuper.stop()inside them, to make sure the start/stop chains can work as expected.
Related issues
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request