Read the statement by Michael Teeuw here.
programming model
-
what is the model being used for both module and helper?
where and how do I declare variables? either global or instance? (not method variables)
in a helper if I declare outside the NodeHelper.create(…), they are truely global, and other helpers will overwrite my variables if the names collide.
-
@sdetweil If you want class variables you can do the following:
module.exports = NodeHelper.create({ variable1: true, // This is one way start: function() { this.variable2 = true // This is another way // Both variables can be accessed via this.VARIABLE_NAME } });
-
thanks…
strange syntax tho…
-
@sdetweil Thats simply how to define a variable inside an object in node.js :grinning_face_with_smiling_eyes:
-
i have a lot of code running in another node/angular mirror app and have never seen this syntax…
-
@sdetweil Wait, I think I misunderstoodyour question.
Do you want to have a class variable just in your
node_helper.js
, or do you want to share a variable betweennode_helper.js
and yourMMM-ModuleName.js
file? -
not class variable (I got that now), but shared would solve a ton of problems.
-
@sdetweil I solved this problem by using
this.sendSocketNotification
This allows me to communicate with the modules interface. -
yeh, but all this notification event handling really messes up the code i have which is all angular promise based.
I want to open my own browserwindow (show image), but u can’t do that in a module, only in a helper,
but then the window handle object needs to be stored inside the object which is managing the list of images for this ‘viewer’. that object is stored in the module… so, how do I transport the window handle object to the module… is the object valid in the other context (helper vs module).see the topic ‘what can i do in a module’. (which u already have)
-
@sdetweil I don’t think that. The helper is running on your Raspberry Pi, the module is running in every browser instance you open.
You need to coordinate your “show image event” from the helper and send out a notification to the module what image to show.
The ViewManagement must be in the module, the image downloading, handling must be in the helper.
Note: You only have one helper, but you can have multiple modules!