Hi folks,
I have a question in regards to the photon and sparkJS events.
Should the Photon respond to an event fired from a web app?
Currently I have a button on my breadboard that publishes an event like so:
// photon
button.on(“press”, function() {
spark.publishEvent('Foo', 'bah');
});
In my expressJS app I have a listener like so:
// web app
spark.onEvent('Foo', function(data) {
console.log("Event: " + data.data);
});
This is great and works as expected - but is it possible to publish an event from the web app back to the photon ?
I had assumed something like the following would work:
// photon
button.on(“press”, function() {
spark.publishEvent('Foo', 'bah');
});
spark.onEvent(‘Baz’, function(data) {
console.log("Event: " + data.data);
});
and …
// web app
spark.onEvent('Foo', function(data) {
console.log("Event: " + data.data);
});
spark.publishEvent(‘Baz’, ‘qux’);
I can see all the events being logged in Dashboard - however I don’t seem to have any reaction from the Photon when Baz
is published - I’ve tried all getEventStream
options and onEvent
.
I have also raised an issue in the SparkJS repo.