Just starting out with JavaScript, I'm attempting to incorporate a JavaScript library/sdk. I've familiarized myself with common patterns and currently considering using the revealing module pattern. To provide a concrete example, let's imagine a scenario where there is a library where people can rent books. This library will offer 2 objects to the application - library and rented_books. To simplify, let's assume this library only keeps track of rented books, not available books.
My plan is to create a file named library.js and place the complete module for the library object within it. Similarly, I will create another module called book.js for the book object. Now, I have a couple of questions:
- How can I establish the relationship between these two objects? Should I use 'new' on the book object when a user wants to rent a book?
- How can I ensure that the book module is loaded before the library object?
Essentially, I'm unsure about the process of creating a library in this manner. Any resources or articles that explain this concept would be greatly appreciated.