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

@ofzza/entt-rxjs

v3.2.7

Published

RxJS compatible extension of enTT - a modular TypeScript data-modeling solution

Downloads

12

Readme

enTT RxJS

enTT-RxJS is a RxJS compatible extension of enTT, read as "Entity" - an extensible TypeScript data-modeling solution with some of the typically required functionality, such as change-detection, easy import/export, composition/decomposition, data validation, etc., all available out of the box and easy to use.

Table of contents:

Get enTT-RxJS

To start using enTT-RxJS in your project, simply install it from NPM by running the following in your terminal:

> npm install @ofzza/entt-rxjs --save

Using enTT-RxJS

Usage of enTT-RxJS is nearly identical to enTT, so please read up on basic usage of enTT first! Covered here will be only what is different from the base enTT implementation ...

Cast accepts RxJS Observables

If passed a RxJS Observable, cast will return a piped Observable which will map any resolved value to a cast instance, in line with how the base enTT library works with Promises, like so:

import { EnTT } from '@ofzza/entt-rxjs';
import { Subject } from 'rxjs';

class MyPersonClass extends EnTT {
  constructor() {
    super();
    super.entt();
  }

  public firstName = undefined as string;
  public lastName = undefined as string;
}

const instance = new MyPersonClass();
instance.firstName = 'John';
instance.lastName = 'Doe';

const serialized = instance.serialize();
console.log(serialized); // Outputs: { firstName: "John", lastName: "Doe" }

const observable = new Subject(),
  castObservable = MyPersonClass.cast(observable, { target: MyPersonClass });
castObservable.subscribe(value => {
  console.log(value instanceof MyPersonClass); // Outputs: true
  console.log(value.firstName); // Outputs: "John"
  console.log(value.lastName); // Outputs: "Doe"
});
observable.next(serialized);
observable.complete();

Exposes RxJS "cast" operator to use with .pipe()

To cast a value as an EnTT in an RxJS pipe user the cast operator, like so:

import { EnTT, cast } from '@ofzza/entt-rxjs';
import { Subject } from 'rxjs';

class MyPersonClass extends EnTT {
  constructor() {
    super();
    super.entt();
  }

  public firstName = undefined as string;
  public lastName = undefined as string;
}

const instance = new MyPersonClass();
instance.firstName = 'John';
instance.lastName = 'Doe';

const serialized = instance.serialize();
console.log(serialized); // Outputs: { firstName: "John", lastName: "Doe" }

const observable = new Subject();
observable.pipe(cast(MyPersonClass)).subscribe(value => {
  console.log(value instanceof MyPersonClass); // Outputs: true
  console.log(value.firstName); // Outputs: "John"
  console.log(value.lastName); // Outputs: "Doe"
});
observable.next(serialized);
observable.complete();

Contributing

Reporting Issues

When reporting issues, please keep to provided templates.

Before reporting issues, please read: GitHub Work-Flow

Contributing Code

For work-flow and general etiquette when contributing, please see:

Please accompany any work, fix or feature with their own issue, in it's own branch (see Git Source-Control Work-Flow for branch naming conventions), and once done, request merge via pull request.

When creating issues and PRs, please keep to provided templates.