yfinkelstein / node-zookeeper

node.js client for Apache Zookeeper
MIT License
479 stars 111 forks source link

What is the different between connect() and init() ? #316

Closed guohaoyun closed 2 years ago

guohaoyun commented 2 years ago

Or When to use connect() and when to use init() ?

DavidVujic commented 2 years ago

Hi @guohaoyun thank you for asking about these two very similar functions.

I would recommend to use the init function together with listeners, as described in the readme: https://github.com/yfinkelstein/node-zookeeper#example-create-a-client

The connect function calls the init function internally, plus the connect handling. But I see that one as a legacy function. I decided to keep it to not cause any breaking features for existing users.

guohaoyun commented 2 years ago

Hi @guohaoyun thank you for asking about these two very similar functions.

I would recommend to use the init function together with listeners, as described in the readme: https://github.com/yfinkelstein/node-zookeeper#example-create-a-client

The connect function calls the init function internally, plus the connect handling. But I see that one as a legacy function. I decided to keep it to not cause any breaking features for existing users.

Thanks for replying!