JSPM

  • Created
  • Published
  • Downloads 1301
  • Score
    100M100P100Q105530F
  • License MIT

A decorator-based library that allows you to fully use RxJS with Angular. Use Observables as first-class citizens in your view templates! Listen to component lifecycle events with Observables! Lithium makes your components highly reactive.

Package Exports

  • @lithiumjs/angular

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@lithiumjs/angular) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Lithium for Angular (@lithiumjs/angular)

Build Status Coverage

A decorator-based library that allows you to fully use RxJS with Angular. Use Observables as first-class citizens in your view templates! Listen to component lifecycle events with Observables! Lithium makes your components highly reactive.

Lithium now supports Ivy as of Angular 9.0.0! Read the FAQ for more info.

Example app - [Live demo]

Introduction

  • Intuitive decorators:

    Lithium is decorator-based and easy to use:

import { OnInit } from '@lithiumjs/angular';

@Component({...})
class MyComponent {

    @OnInit() 
    private readonly onInit$: Observable<void>;

    constructor () {
        this.onInit$.subscribe(() => console.log("Reactive ngOnInit!"));
    }
}
  • Full reactive template binding:

    Lithium's @StateEmitter lets you pass Observables directly as inputs to any component and two-way bind Subjects directly to ngModel.

  • Works with Angular component decorators:

    You can use Angular's built-in component decorators with Lithium. Use an @Input as a Subject and listen to a @HostListener event as an Observable!

  • OnPush components made easy:

    With Lithium, writing more performant components using OnPush change detection is simple; just enable AutoPush!

  • Like async, but better:

    Lithium automatically manages subscription lifetimes just like Angular's async pipe, without its syntax overhead (and ugly workarounds).

  • Integrates with other reactive decorators:

    Lithium can be used in conjunction with other reactive decorator-based libraries like NGXS.

Read through the intro guide to get to know Lithium's core features and view the example app to see Lithium in action with real-world use-cases. Full API documentation is also available.

Lithium supports Angular's new Ivy compiler. Read here for more info.

Installation

Lithium can be installed via npm using the following command:

npm install @lithiumjs/angular

FAQ and Other information

FAQ

Does Lithium support ViewEngine (Ivy opt-out, Angular pre-9)

Lithium currently supports both ViewEngine and Ivy builds. Lithium will automatically detect which compiler is being used in your app.

Does Lithium support Ivy (Angular 9 default compiler)?

Yes, Lithium fully supports Ivy as of Angular 9.0.0. However, Lithium uses features from the not-yet finialized Ivy API, so some features could stop working in later versions of Angular 9 before Lithium is updated to support them.

If you are upgrading an existing Lithium-enabled app to Ivy, you should read the Ivy upgrade guide for Lithium.

Are there any known limitations with Lithium?

While Lithium integrates cleanly with Angular for the majority of cases, there are certain limitations that are noted here.

Other information