Skip to content

wuchuheng/rxjs

Repository files navigation

Reactive extension for javascript.

Description

This is a library for communication between components, similar to redux, but it is simpler and easier to use.

Installing

$ npm i @wuchuheng/rxjs

Usage

step1 declare Scheduler for communication between components

import SubscriptionService from "@wuchuheng/rxjs";

// This is a scheduler where all the subscribers will be stored
class Scheduler {
    public static chatGroupObserve = new SubscriptionService<string>('');
}

step2 usage directly in components

import {useObserve} from "@wuchuheng/rxjs";

const componentA = () => {
    const [message, dispatcher] = useObserve(Scheduler.chatGroupObserve); 
    // a new message will be dispatch here. 
    return <input onchange={e => dispatcher.next(e.target.value)} />
}

const componentB = () => {
    // This hook will subscribe to the new message.
    const [message] = useObserve(Scheduler.chatGroupObserve);
    return <>{message}</>
}

You can contribute in one of three ways:

  1. File bug reports using the issue tracker.
  2. Answer questions or fix bugs on the issue tracker.
  3. Contribute new features or update the wiki.

The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.

License

MIT

About

Reactive extensions libery for javascript.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published