Skip to content

New Puppet Abstract API: onStart() & onStop #163

Open
@huan

Description

@huan

Wechaty Puppet v0.49 and the previous version, we need to implement the start() and stop() on child class, and we need to manage the state by ourselves, like:

puppet/src/puppet/puppet.ts

Lines 138 to 142 in e76d675

if (this.state.on()) {
log.warn('Puppet', 'start() found that is starting/statred...')
await this.state.ready('on')
log.warn('Puppet', 'start() found that is starting/statred... done')
return

From v0.51, we can reuse those codes from the abstract base class, and we can put all our function code in onStart() and onStop(), without care about the state anymore.

The start() and stop() method in the Puppet abstract base class will take care of the state and call onStart() and onStop for you.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions