Immutable objects have multiple advantages over mutable objects which makes them the perfect building block to create software. You may already have many questions about the subject like:
Why should I use immutable over mutable objects?
How can I design software where no single object can be modified?
You'll see in this article what an immutable object is, the advantages to use them every time you can and how they can speed up your software developments.
To make it simple, a class is immutable when instances of this class cannot be changed once constructed. Immutable objects follow five rules, like explained in Java Effective by Joshua Bloch:
It involves mocking the Angular2 Http service, and it's far more complicated than unit testing the Router service.
I first tried to inject a mock of the Http service and return custom Observable responses but this led to strange errors and cumbersome code.
I quickly switched to the recommended way, using MockBackend.
This post is an example of TypeScript generics usage, when writing an Angular2 application.
I'm working on a Stripe administration console. Stripe is a payment / subscription SaaS service that we use at OctoPerf.
I need to create pages that lists all our customers and plans. But Stripe returns paginated lists, and we need to do successive calls to their API to get the complete data.
This mechanism is the same for both customers and plans lists. So we can factorise our code using generics in this particular case.