title: Lazy loading Pattern with Typescript
body: <p>So with C# and other languages where you have a get and set assessor on properties, it's quite simple to build a lazy loading pattern.</p>
  
  <p>I only recently started playing with Type Script and I'm trying to achieve something the same. I'm loading a Poco with most of it's properties via a Ajax Call. The problem can be described below:</p>
  
  <pre><code>export interface IDeferredObject&lt;T&gt; {
      HasLoaded: boolean;
      DeferredURI: string;         
  }
  
  export class Library{        
  
      LibraryName: string;
      Books: IDeferredObject&lt;Book[]&gt;;        
  }   
  
  export class Book {
      Title: string;
      UniqueNumber: number;
  }
  
  
  
  window.onload = () =&gt; {
      //Instantiate new Library
      var lib = new Library();
  
      //Set some properties
      lib.LibraryName = "Some Library";
  
      //Set the Deferred URI Rest EndPoint
      lib.Books.DeferredURI = "http://somerestendpoint";
      lib.Books.HasLoaded;      
  
  
  
      //Something will trigger a  GET to lib.Books which then needs to load using the Deferred Uri       
  
  };
  </code></pre>
  
  <p>Couple of questions: 
  I</p>
  
  <ul>
  <li>Is a Interface even the right thing to use here?</li>
  <li>I'd like to trigger a Load action when something accesses the Library Books Property. Is this even possible?</li>
  </ul>
  
  <p>I know it's quite an open question, just looking for some guidance on how to build that pattern.</p>
  
  <p>Thanks</p>