JS beginner here, trying to implement JS library/sdk. Have read through the common patterns and planning to use revealing module pattern as of now. For context, lets take an example. We have a library and people can rent books from library. So the library will expose 2 objects to application - library and rented_book. For simplicity, lets say this library does not maintain list of available books but just rented books.
Now I will create a file called library.js and put the complete module for library object in it. And create another module book.js and code for the same in it. Now my doubts are
- How do I create the relationship between these two objects. When a user wants to rent a book, should I do a new on the book object and create it
- How do I make sure that the book module is loaded before the library object?
Basically, I am confused on how to create a library in this way. Any links to stuff that explain this will help a lot.
Aucun commentaire:
Enregistrer un commentaire