yfinkelstein / node-zookeeper

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

What is the use of watcher<boolean> in the APIs? #326

Closed 24x7soumya closed 1 year ago

DavidVujic commented 1 year ago

Hi @24x7soumya!

When set to true, there should be a watcher added and events are sent to the client. There's corresponding functions where you can pass explicit callback functions. I don't remember if I've ever used a true value when using the one with booleans, though.

I think this is the place where it is done from the C wrapper: https://github.com/yfinkelstein/node-zookeeper/blob/master/src/node-zk.cpp#L481

And re-emitted in the JavaScript client: https://github.com/yfinkelstein/node-zookeeper/blob/master/lib/zookeeper.js#L79

24x7soumya commented 1 year ago

Thanks for the response @DavidVujic . It is a bit confusing about how the event will be received. But I got the idea.