The package allows a developers to use features from Angular Ivy.
The Angular Ivy runtime introduces a new concept called component features. In the release of Ivy, component features are not publically available. However, component features are applied internally by Angular to all components.
Component features are mixins for components. They add, remove or modify traits at runtime.
Custom decorators are questionable. After several years, they are still not ratified in an ECMAScript standard. Their syntax or semantics might change. Hence, they might never make it into the language, rendering them in limbo in TypeScript and other transpiled languages. Additionally, custom decorators are by default not tree-shakable.
Warning! This feature is experimental and can include known and undiscovered errors.
- Angular 14 support 🥳
Angular 14 | Angular 13 | Angular 12 | Angular 11 | Angular 10 | Angular 9 |
---|---|---|---|---|---|
>=v14.0.1 |
>=v13.0.1 |
>=v12.0.1 |
>=v11.0.1 |
>=v10.0.1 |
>=v9.0.1 |
The library contains common code for ngx-cocktail features
npm install @ngx-cocktail/common
import { Features } from '@ngx-cocktail/common';
@Features([YourFeature()])
export class AppComponent implements OnInit {}
The library contains code for destoyable feature
npm install @ngx-cocktail/common @ngx-cocktail/destroyable
import { Features } from '@ngx-cocktail/common';
import { DestroyableFeature } from '@ngx-cocktail/destroyable';
@Features([DestroyableFeature()])
export class AppComponent implements OnInit {
public destroyed$!: Observable<unknown>;
ngOnInit(): void {
interval(1000)
.pipe(takeUntil(this.destroyed$))
.subscribe((value) => {
...
});
}
}
The library contains code for title feature.
The feature sets the title of a current HTML document. Underhood, it injects Title from '@angular/platform-browser' and set your custom title.
Notes:
- If there are parent and nested components with TitleFeature, it will use nested.
- The title should be handled manually defining them on components
npm install @ngx-cocktail/common @ngx-cocktail/title
import { Features } from '@ngx-cocktail/common';
import { Title } from '@ngx-cocktail/title';
@Features([TitleFeature('My Website: My Title')])
export class AppComponent implements OnInit {}