This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//////////////////////////////////////////////////////////////////////////////////////////// | |
// In Angular, we often use *RxJS* observables. // | |
// // | |
// A frequent usecase of observables within Angular component is to have a subscription // | |
// to an observable for the whole lifetime of that component. // | |
// // | |
// To do this, we need to subscribe when the component comes up, // | |
// and we will *HAVE to* unsubscribe when the component is destroyed. // | |
// (Seriously, not unsubscribing will lead to memory leaking everytime the component gets // | |
// destroyed.) // |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// When programming, there will certainly be times you will want to associate values to other values, | |
// that is building a dictionary. | |
// In TypeScript, a `Map<K, V>` exists (it seems it actually is the one defined in JavaScript ES6). | |
// However, at least in TypeScript 3.1.6, objects from this class are not very reliable: | |
// You will sometimes get errors such as "TypeError: map.get is not a function", at seemingly random times. | |
// A solution is to replace `Map<string, V>` by plain objects defined as `{ [key: string]: V }`. | |
// Another solution seems to be to replace them by `Record<string, V>`. | |