npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

reactive-forms-extension

v1.0.0-rc12

Published

A simple toolkit for Angular Reactive Forms, to build scalable, type-safe and dynamic forms.

Downloads

1

Readme

ng-rfx - Angular Reactive Forms Extension

A simple toolkit for Angular Reactive Forms, to build scalable, type-safe and dynamic forms.

THIS LIBRARY IS IN RELEASE CANDIDATE MODE AND THE CODE AS WELL AS THE DOCUMENTATION IS NOT YET CONSIDERED STABLE!

Project Documentation Website: [https://syncrea.github.io/ng-rfx/]

Reduce the complexity of your form implementations

Have you ever implemented large and dynamic forms using the standard Angular Reactive Forms module? If you have, you probably know the pain of implementing forms in your application. This library aims to solve this by providing the necessary toolkit to build scalable forms.

Key features of ng-rfx

  • Design your forms using simple TypeScript interfaces!
  • Type-safety from design to implementation
  • Create forms declaratively using form definitions
  • Centralized form registry with typed keys to maintain type-safety
  • Redux / ngrx friendly by using serializable keys
  • Binding directive to obtain typed form controls and state directly in your view!

Installation

npm install --save ng-rfx

Usage

Form Model and Typed Form Controls

One of the core features of ng-rfx is to provide simple type-safety for your forms. You can leverage the utilities of ng-rfx without importing any NgModule in your application. Just use ng-rfx typed form controls over the standard form controls of Angular. Start by defining your forms using a simple interface.

interface SimpleForm {
  firstName: string;
  lastName: string;
}

Now you can use the typed form controls of ng-rfx and get rid of the no. 1 pain while implementing forms. Missing type information in forms can ruin the day (and your whole project!).

import {TypedFormGroup, TypedFormControl} from 'ng-rfx';

const control = new TypedFormGroup<SimpleForm>({
  firstName: new TypedFormControl<string>('First name'),
  lastName: new TypedFormControl<string>('Last name')
});

Typed form controls are inheriting from their counterpart in the standard Angular forms module. We know three types of form controls:

|ng-rfx control | inherits from | Type-safe API |:--------------------|:--------------|--- | TypedFormControl | FormControl | constructor(formState?: T, validatorOrOpts?: ..., asyncValidator?: ...) | | | get typedValue(): T | | | patchValue(value: T, options?: {...} | | | setValue(value: T, options?: {...} | | | reset(formState?: T, options?: {...} | | | get typedValueChanges(): Observable<T> | TypedFormGroup | FormGroup | constructor(controls?: {[K in keyof F]: TypedFormGroupChildInternal<F, K>}, validatorOrOpts?: ..., asyncValidator?: ...) | | | get typedValue(): F | | | typedGet<K extends keyof F>(key: K): TypedFormGroupChildInternal<F, K> | | | patchValue(value: Partial<F>, options?: {...}) | | | setValue(value: F, options?: {...} | | | reset(formState?: F, options?: {...} | | | get typedValueChanges(): Observable<F> | TypedFormArray | FormArray | constructor(controls?: T extends PrimitiveType ? TypedFormControl<T>[] : TypedFormGroup<T>[], validatorOrOpts?: ..., asyncValidator?: ...) | | | get typedValue(): T[] | | | typedAt(index: number): T | | | patchValue(value: T[], options?: {...}) | | | setValue(value: T[], options?: {...} | | | reset(formState?: T[], options?: {...} | | | get typedValueChanges(): Observable<T[]>

You can use the new typed methods to handle your forms in a type-safe way:

control.setValue({
  firstName: 'Updated first',
  lastName: 'Updated last'
});

Inside of your view, you can access the typed children of your form group to create form control bindings:

<input [formControl]="control.typedGet('firstName')"  type="text">

... documentation to be continued