You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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 PuppetSkelton as the base abstract class for all Mixins, it
extends the PuppetEventEmitter for adding the listener typings
has the least components to support other mixins
All functionalities will be added by mixin, for example:
CacheMixin for puppet.cache related codes
WatchdogMixin for puppet.watchdog related codes
MemoryMixin for puppet.memory related codes
MessageMixin, ContactMixin, RoomMixin, etc to add related puppet abstract APIs
All mixins need to implement a start() and stop() and call super.start() and super.stop() inside them, to make sure the start/stop chains can work as expected.
Uh oh!
There was an error while loading. Please reload this page.
What is Mixin
Mixin is a great decouple and design pattern to split the puppet class logic into different files.
Wechaty Puppet Mixins
PuppetSkelton
as the base abstract class for all Mixins, itPuppetEventEmitter
for adding the listener typingsCacheMixin
forpuppet.cache
related codesWatchdogMixin
forpuppet.watchdog
related codesMemoryMixin
forpuppet.memory
related codesMessageMixin
,ContactMixin
,RoomMixin
, etc to add related puppet abstract APIsstart()
andstop()
and callsuper.start()
andsuper.stop()
inside them, to make sure the start/stop chains can work as expected.Related issues
The text was updated successfully, but these errors were encountered: