From 00a0abd03072047e06a9ccabb3cb16b81091a37a Mon Sep 17 00:00:00 2001 From: Alex Tereschenko Date: Mon, 28 Mar 2016 18:41:43 +0200 Subject: [PATCH] isr.js: updated JS ISR example to avoid GPIO context being destroyed Closes #403. Signed-off-by: Alex Tereschenko Signed-off-by: Brendan Le Foll --- examples/javascript/isr.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/examples/javascript/isr.js b/examples/javascript/isr.js index d400c0d..9abcb1f 100644 --- a/examples/javascript/isr.js +++ b/examples/javascript/isr.js @@ -8,3 +8,9 @@ function h() { x = new m.Gpio(14) x.isr(m.EDGE_BOTH, h) + +setInterval(function() { + // It's important to refer to our GPIO context here, + // otherwise it will be garbage-collected + console.log("Waiting for an interrupt at GPIO pin " + x.getPin() + "...") +}, 10000)