Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Stop reader #39

Closed
glints opened this issue Mar 13, 2018 · 1 comment
Closed

Stop reader #39

glints opened this issue Mar 13, 2018 · 1 comment

Comments

@glints
Copy link

glints commented Mar 13, 2018

Is there a way to stop the reader from listening? If I use reader.close(), the entire node.js process stops (on mac). reader.disconnect() doesn't work either. Reader keeps listening.

reader.on('card.off', card => {

            try {

              reader.emit('end');


          	} catch (err) {
          		console.error('error when reading data', err);
          	}
});

reader.on('end', () => {

          reader.close();
});

I basically want to have an interface with a button 'read NFC' and on click it needs to listen for nfc input, but once the card leaves and input is read, I want the nfc process killed. Help would be much appreciated.

@glints
Copy link
Author

glints commented Mar 14, 2018

Got it, just changed the on. to once. so the event happens only once. Fairly new to node.js here...

@glints glints closed this as completed Mar 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant