Using IMAP IDLE it is possible to listen for new mail and delete mail events. I used node-imap module in node.js to do that. But is it possible to listen for the flag change events like mark as read, unread and also folder creation/deletion/rename events?
I read about IMAP NOTIFY extension here they specified imap client but it seems gmail is not supporting it and also in node.js I can't find anymodules that implemented this "IMAP NOTIFY". Please give any suggestion to achieve this.
As for the flag and keyword changes, yes, the IDLE
extension was designed just for this purpose. Please note that gmail does not report flag changes when in IDLE. The linked thread contains a workaround. GMail's behaivor is completely breaindead, of course.
As for other changes, the NOTIFY extension is what you are looking for, but its support among servers is rather scarce -- only Dovecot, AFAIK. If your favorite IMAP client library doesn't offer it already, you should ask their authors.