Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
huan opened this issue Oct 17, 2021 · 0 comments
Open

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

huan opened this issue Oct 17, 2021 · 0 comments
Labels
enhancement New feature or request

Comments

@huan
Copy link
Member

huan commented Oct 17, 2021

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant