go-zookeeper icon indicating copy to clipboard operation
go-zookeeper copied to clipboard

how to know the value before watch event?

Open xiaoyulei opened this issue 8 years ago • 2 comments

If I watch a path, when the value changed/delete/create, how to know the prev-value and latest value?

xiaoyulei avatar Aug 29 '16 08:08 xiaoyulei

no! u should save the value and deal with the value changing

junweiyang avatar Nov 14 '16 09:11 junweiyang

You first read the node data with GetW which returns the lastest value (as you need) and a channel that you listen to new change event on that node. When such an event comes you have to invoke GetW again and get the new latest value and a channel for events. Now, you have the previous value, the latest value and a channel for new events.

ioanvapi avatar Dec 14 '17 08:12 ioanvapi