From c765f46aa72c19e7268ef313de8c472d618a877b Mon Sep 17 00:00:00 2001 From: Roberto Simonetti Date: Fri, 7 Apr 2017 21:11:18 +0200 Subject: [PATCH] Update doc & version --- doc/spec.md | 23 +++++++++++++++++++++-- package.json | 2 +- 2 files changed, 22 insertions(+), 3 deletions(-) diff --git a/doc/spec.md b/doc/spec.md index 80b9c9fb..9b90da09 100644 --- a/doc/spec.md +++ b/doc/spec.md @@ -1,5 +1,5 @@ # Angular localization library specification -Library version: 3.0.2 +Library version: 3.0.3 ## Table of contents * [1 Library structure](#1) @@ -14,6 +14,7 @@ Library version: 3.0.2 * [3.1.1 Messages](#3.1.1) * [3.1.2 Dates & Numbers](#3.1.2) * [3.1.3 OnPush ChangeDetectionStrategy](#3.1.3) + * [3.1.4 ngOnDestroy method](#3.1.4) * [3.2 Directives](#3.2) * [3.3 Getting the translation in component class](#3.3) * [4 Changing language, default locale or currency at runtime](#4) @@ -311,6 +312,24 @@ export class HomeComponent extends Localization { } ``` +#### 3.1.4 ngOnDestroy method +When you extend `Translation` or `Localization` classes, the component inherits +`ngOnDestroy` method that cancels the subscriptions to update the pipes parameters. +If you override the `ngOnDestroy` method in your component to cancel its subscriptions, +you should call also `cancelPipesSubscriptions`: +```TypeScript +ngOnDestroy() { + // Cancels the subscriptions of the component. + this.subscriptions.forEach((subscription: ISubscription) => { + if (typeof subscription !== "undefined") { + subscription.unsubscribe(); + } + }); + + this.cancelPipesSubscriptions(); +} +``` + ### 3.2 Directives Type | Format | Html syntax ---- | ------ | ----------- @@ -344,7 +363,7 @@ Parameters: ``` *N.B. You can dynamically change attributes, parameters and expressions values. If you use in the component only the directives and not the pipes, -you don't need to import services and extend `Translation` or `Localization` class.* +you don't need to import services and extend `Translation` or `Localization` classes.* ### 3.3 Getting the translation in component class To get the translation in component class, `TranslationService` has the following methods: diff --git a/package.json b/package.json index bbf1b730..117dee60 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "angular-l10n", - "version": "3.0.2", + "version": "3.0.3", "description": "An Angular library to translate messages, dates and numbers", "main": "./bundles/angular-l10n.umd.js", "module": "./modules/angular-l10n.es5.js",