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

1.adjust the ready function #246

Closed
wants to merge 2 commits into from
Closed

1.adjust the ready function #246

wants to merge 2 commits into from

Conversation

beanjs
Copy link

@beanjs beanjs commented Nov 5, 2019

Adjust the ready function to allow multiple registration callback functions

@StarpTech
Copy link
Member

Hi, what's the issue you want to solve? Please add a proper description.

@coveralls
Copy link

coveralls commented Nov 5, 2019

Coverage Status

Coverage decreased (-0.1%) to 96.603% when pulling 9d5eef5 on beanjs-framework:master into f08d7a7 on hemerajs:master.

@beanjs
Copy link
Author

beanjs commented Nov 5, 2019

I want to use hemera like the fastify framework, but in hemera, I can only use the registration of ready once, but not multiple times, so I can't nest the ready registration function internally when writing the hemera plugin.

@StarpTech
Copy link
Member

Could you make an example?

@beanjs
Copy link
Author

beanjs commented Nov 5, 2019

`
const hemera=new hemera(nats,{})

hemera.register(hemeraPlugin((h,opts,done)=>{
h.ready(()=>{
console.log("this is ready call back in plugin")
})
done()
}))

hemera.ready(()=>{
console.log("this is ready call back")
})

`

this._transport.driver.on('connect', () => {
this.log.info('Connected!')

this._isReadyWaits.forEach((readyCall)=>{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this doesn't work because you call _registerEvents in the constructor. At that time no user has registered a ready callback handler.

this._transport.driver.on('disconnect', () => {
this.log.warn('NATS disconnected!')
})
// if (this._isReady) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove comments if you are done.

@@ -18,7 +18,9 @@ describe('Hemera', function() {
const hemera = new Hemera(nats)
hemera.ready(() => {
try {
hemera.ready()
hemera.ready(()=>{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's that?

@@ -64,6 +64,7 @@ class Hemera {

this._root = this
this._isReady = false
this._isReadyWaits = []
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

is expresses a boolean value this is a list.

@beanjs
Copy link
Author

beanjs commented Nov 15, 2019

I have developed my own beanify microservice framework to replace Hemera

@beanjs beanjs closed this Nov 15, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants