wechaty / puppet

Puppet Provider Abstraction for Wechaty
https://wechaty.github.io/wechaty-puppet
Apache License 2.0
231 stars 52 forks source link

Create a Interface for Puppet #105

Open huan opened 4 years ago

huan commented 4 years ago

When we are developing Wechaty with Puppet Providers, we will always face an error of instanceof mismatch, like

  1. https://github.com/wechaty/wechaty/issues/1930
  2. https://github.com/wechaty/wechaty/issues/2024

According to https://stackoverflow.com/a/47116527/1123955, we can define an Interface for our AbstractPuppet class:

interface Puppet extends AbstractPuppet {
}

After that, we can always use the Interface of Puppet and never use instanceof again, for a better and a beautiful duck typing world.

huan commented 4 years ago

A workaround for now: https://github.com/wechaty/wechaty/commit/2e951b7538540a5a94a867ad46ac86721a7c33af

huan commented 4 years ago

Related to https://github.com/wechaty/wechaty/issues/1930