Skip to content

increased clarity for readme example? #2

@DTrejo

Description

@DTrejo

Hey,
The example confused me, so this is my attempt to make it more clear, is my clarification correct?
Thanks,
D

elect(opts, function(err, node) {
   if (node.leader) {
     console.log('Hooray! I am the leader!');
   } else {
+    // you are not the leader, but might be elected at some later time.
     node.on('leader', function() {
-      console.log('I got elected as the leader!');
+      console.log('Old leader is down, and I was just elected as the leader!');
     });
   }
 });

Note that the example will not run out of the box because /my/service/path may not yet exist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions