Using Inner Libraries

Display hides some js libraries you can use.
Some are simple functions answering a direct value.
Some are external calls to various sources, and give an asynchronous answer.
In this case your Sensor needs to have a special Input function.

1 - you call the library for an external query.
2 - the library finds the info.
3 - the library calls the Input function inside your Sensor injecting the requested data inside an array.
4 - your Input function has now all you needed and will trigger other functions inside the Sensor instance


the Input function inside your Sensor


Custom.prototype.Input=function(arr,key){ }



arr - the array containing the requested info
key - a string value used to identify the answer

all calls to a lib usually contain a key, the key is then sent back to Input, so you can recognise the call.

getPoloniexPair(pair,amount,key,id)

An example call to a lib from a Sensor, the lib calls the internet and sends back an array of data to Input

getPoloniexPair("BTC_ETH",5,"QUESTION 1",this.id); 


now the lib calls the internet

...

after a while Input is triggered

Custom.prototype.Input=function(arr,key){ // arr now contains informations about Bitcoin and Ethereum // key now = "QUESTION 1" } Wherever you are, you may be interested in calling that Input function, that belongs to a specific Sensor, and in passing it some informations, so you need the id of the Sensor: Sensor[id].Input(your_arr,"your_key"); This is why when you call a lib, usually you have to pass to it the id of the calling Instance, so the system can call you back at the right location. All Libraries are listed here: