Your Universal Remote Control Center
RemoteCentral.com
Philips Pronto Professional Forum - View Post
Previous section Next section Up level
Up level
The following page was printed from RemoteCentral.com:

Login:
Pass:
 
 

Topic:
Problem using modules
This thread has no replies.
Post 1 made on Saturday December 4, 2010 at 13:27
npz
Lurking Member
Joined:
Posts:
October 2010
1
Hi all,

I am trying to control various pieces of hardware from different activities.

It seems logical to put the code for controlling these things in external libraries, which can be imported into each activity, with various functions that control each device made available to the activity/page. I do this by using name spaces to avoid polluting the global scope, as suggested by Flanagan:

com.example.Module = {}

(function() {
var privateVar;
/*function declarations/init code/etc*/

//Export public functions:
var ns = com.example.Module;
ns.function1 = function(){return privateVar;};
})();


This means it's easy to reuse code in different activities.

The problem is when I try and import 2 modules that have functions with the same name - they seem to clash even though they are in two different name spaces.

This results in commands meant for the device controlled in the first module being sent to the device defined in the next.

System.include("com.example.Module1");
System.include("com.example.Module2");
mod1 = com.example.Module1;
mod2 = com.example.Module2;
mod1.send("command1");
mod2.send("command2");


Both commands get sent as if I had typed:

mod2.send("command1");
mod2.send("command2");


I don't understand why this would happen as they are declared in completely separate name spaces, can anyone shed any light on this situation?

Many thanks for reading.

Jump to


Protected Feature Before you can reply to a message...
You must first register for a Remote Central user account - it's fast and free! Or, if you already have an account, please login now.

Please read the following: Unsolicited commercial advertisements are absolutely not permitted on this forum. Other private buy & sell messages should be posted to our Marketplace. For information on how to advertise your service or product click here. Remote Central reserves the right to remove or modify any post that is deemed inappropriate.

Hosting Services by ipHouse