[minor] Introduce `reconnected` event
[fix] Only write data when the data is not undefined, we cannot write a 0.
[test] Added new tests for event and data
[doc] Documented the new event.