title: Sharing instantiated objects in requirejs
body: <p>I'm defining a module <code>Foo</code> and I am instantiating it within another module <code>Bar</code>. I have a third module <code>Other</code> which I'd like to provide with the same instance of <code>Foo</code> that <code>Bar</code> created and modified.</p>
  
  <pre><code>define('Foo', [], function() {
      var test = function() {
          this.foo = 'foo';        
      };
  
      return test;
  });
  
  define('Bar', ['Foo'], function(Foo) {
      Foo = new Foo();
      Foo.bar = 'bar';
      console.log('From bar', Foo);
  });
  
  define('Other', ['Foo'], function(Foo) {
      console.log('From the other', Foo);
  });
  
  
  require(['Foo', 'Bar', 'Other'], function(Foo, Bar, Other) {
      console.log('Bringing it all together');
  });
  </code></pre>
  
  <p><a href="http://jsfiddle.net/radu/Zhyx9/" rel="noreferrer">http://jsfiddle.net/radu/Zhyx9/</a></p>
  
  <p>Without require, I would be doing something like:</p>
  
  <pre><code>App = {};
  
  App.Foo = function() {
      this.foo = 'foo';
  }
  
  App.Bar = function() {
      App.Foo = new App.Foo();
      App.Foo.bar = 'bar';
      console.log('From bar', App.Foo);
  }
  
  App.Other = function() {
     console.log('From other', App.Foo);
  }
  
  App.Bar();
  App.Other();
  </code></pre>
  
  <p><a href="http://jsfiddle.net/radu/eqxaA/" rel="noreferrer">http://jsfiddle.net/radu/eqxaA/</a></p>
  
  <p>I know I must be missing something here and since this is one my first forays in requirejs there is probably some sort of misunderstanding mixed in. The example may look contrived but I'm coming across something similar in shoehorning a project into using Backbone and RequireJS.
  ​</p>