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

@jhoguet/react-rxjs

v0.0.5

Published

bringing react and rxjs, and IOC together

Downloads

7

Readme

@jhoguet/react-rxjs

:exclamation: Use with caution, this is still in the proof of concept phase and lacks adequate testing both in automated tests and in the wild.

Getting Started

npm install @jhoguet/react-rxjs

Simple Example

import React, { Component } from 'react';
import ReactDOM from 'react-dom';
import { IOCContainer, DependencyInjectableStreamComponent } from '@jhoguet/react-rxjs';
import { BehaviorSubject } from 'rxjs';
import 'aurelia-polyfills';

class HappinessViewModel{
    constructor(){
        this.happiness$ = new BehaviorSubject(1);
        this.increment = () => this.happiness$.next(this.happiness$.value + 1);
    }
}

class AppView extends Component {
    render(){
        const props = this.props;
        return (
            <div>
                <h1>Happiness {props.happiness}</h1>
                <button onClick={e => props.increment()}>Happier!</button>
            </div>
        );
    }
}

class App extends DependencyInjectableStreamComponent {
    static inject(){
        return {
            happiness : HappinessViewModel
        };
    }
    getRenderStream(){
        return this.happiness.happiness$.map(happiness => {
            return {
                happiness,
                increment : () => this.happiness.increment()
            };
        })
        .map(props => {
            return <AppView {...props} />
        });
    }
}

const el = document.createElement('div');
ReactDOM.render(
    <IOCContainer>
        <App />
    </IOCContainer>
    , el
);
document.body.appendChild(el);

So much to cover... submit an issue to encourage me to pump out the api docs...

Intent

The intent of this is to provide a means of building a complex application leveraging the strenths of IOC, React, and RxJS Streams. You should be able easily use any react components.

You should be able to use the same tools (rxjs and IOC) to manage the state / logic of both a "Smart" component like a dropdown (eg open state) as you do complex components (like your entire application.

You should be able to easily have multiple independent instances of any component, something that is not trivial in a system leveraging global stores.

Assumptions / Constraints

  • this is using aurelia-dependency-injection which is a great IOC container, but is rather large (mostly because of corejs and forces you to use classes. Ideally an IOC container in Javascript would also support functions... in effect currying dependencies.
  • DependencyInjectableStreamComponent has to wrap the component in order for the react-debugger to see the component... dig in to this to better understand options and expose the best abstraction for consumers?
  • IOC isn't strictly necessary in this repo... consider splitting out the IOC part from the Stream part?
  • add an IOC opt-out option which uses a container to build everything without the consumer knowing there was ever a container?

Similar Projects

  • http://cycle.js.org/ ands its sister https://github.com/pH200/cycle-react

Next Steps / How to help

  • automated tests in a browser (real dom)
  • docs...
  • research IOC solutions
  • research state of decorators... time to bring in @inject()?