Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
building_on_node_and_exposing_functionality [2012/12/08 03:51]
admin [Exposing Events]
building_on_node_and_exposing_functionality [2012/12/08 03:52] (current)
admin [Exposing Events]
Line 7: Line 7:
 By default node js files only have scope within the same file. We can use the nodejs method "​export"​ to export what ever we need to expose functions or variables ​ By default node js files only have scope within the same file. We can use the nodejs method "​export"​ to export what ever we need to expose functions or variables ​
  
-<code javascript>​+<code javascript ​| myFile.js>
 var x = 5; var x = 5;
 var addX = function(value) { var addX = function(value) {
Line 14: Line 14:
 module.exports.x = x; module.exports.x = x;
 module.exports.addX = addX; module.exports.addX = addX;
 +</​code>​
 +
 +
 +This is then included into other scripts with 
 +
 +<code javascript>​
 +var myExposedStuff ​ = require('​./​myFile'​);​
 </​code>​ </​code>​
  
 
building_on_node_and_exposing_functionality.txt · Last modified: 2012/12/08 03:52 by admin
 
RSS - 200 © CrosswireDigitialMedia Ltd