jpillora / xdomain

A pure JavaScript CORS alternative
https://jpillora.com/xdomain/
3.12k stars 269 forks source link

Feature: Api to get configured slaves #147

Closed ranzwertig closed 9 years ago

ranzwertig commented 9 years ago

It would be nice to get the configured slaves with a funciton like:

xdomain.getSlaves()

I need this in the following scenario:

I have module X which has xdomain for dependency. Module X needs to make sure, that if there is no xdomain on the page it will be included and all the relevant slaves are configured. On Page Y I now use module X. It is now possible that Y has a dependency to xdomain itself or not. If it has, X has to use and reconfigure xdomain when loaded.

jpillora commented 9 years ago

Sorry forgot to reply to this issue. xdomain.masters and xdomain.slaves is used to store each. So you can enumerate them with:

for(var origin in xdomain.slaves) {
  var proxy = xdomain.slaves[origin];
  console.log(origin + proxy);
}