These are my some personal thoughts about Angular2-Meteor project after using it a while, hope it can benefit the community.
Socially tutorial is a well-written tutorial, but it just helps you understand how you can connect Angular 2 and Meteor. It took me a while to realize this. For real use case, you need more.
For a real project, you need follow Angular 2 pattern. For example, you shouldn’t subscribe data in component, instead you should do it in the service (how to use service is not covered in Socially tutorial, but service is very very important). If you subscribe same data in different components, the performance is very very bad.
For the package angular2-meteor-accounts-ui, it is just for demo show and for quick prototype. I would not use it in any of my real projects. The reasons are below:
- You don’t need
@RequireUser(). A better way is to limit user access in router level. Write a custom Directive which extends RouterOutlet. This only needs one file, instead of using
@RequireUser()in every component. And it can let you write complex logic easily to control your the access.
- You don’t need
@InjectUser(). If you have custom fields rather than
profilefield of the user, you still need subscribe by yourself. And if you subscribe the currentUser data in different components. It will make the performance very very bad.
- For a real project, you also need custom your sign up and login UI.
Without using angular2-meteor-accounts-ui, you need write your own currentUser service with RxJS 5 (BehaviorSubject in this case) and use dependency injection. This can make your app at least 10x faster instead of resubscribing same collection again and again.
Note RxJS 5 is not necessary, but once you start to use it, it will help you save a lot of time writing codes and make your app logic clean! You will find RxJS 5 is soooo amazing! (Note
EventEmitter uses Observable inside, but not enough). Most time, you still want to use
AsyncSubject from RxJS 5).
Most questions you will meet in the future is actually either Angular 2 or Meteor problem. Angular2-Meteor is just help connect Angular 2 and Meteor.
Angular 2 and Meteor are very big. So learn Angular 2 and Meteor separately, go deep, and then use them together! Keep learning!